A function for descriptive statistics with R
I wrote this function to prepare summary statistics of regression models. In such a table I typically include mean, standard deviation, minimum, and maximum. The function can be directly apply to outputs of general regressions models such as lm() or glm(). Then I may save the results in a csv file, and run Excel2LaTeX to get LaTeX codes.
#. The function is:
------------------------------------------------------------
msummary <- function(M){
n <- dim(M$model)[2]
s <- matrix(NA,dim(M$model)[2],5)
for (i in 1:n) {
s[i,] <- cbind(mean(as.numeric(M$model[,i])),
sd(as.numeric(M$model[,i])),
min(as.numeric(M$model[,i])),
median(as.numeric(M$model[,i])),
max(as.numeric(M$model[,i])))
}
S <- data.frame(s)
colnames(S) <- cbind("Mean","St.D.","Min","Median","Max")
S$N <- rep(dim(M$model)[1],dim(M$model)[2])
rownames(S) <- names(M$model)
S
}
------------------------------------------------------------
#. An example:
------------------------------------------------------------
> M1.c$call
glm(formula = OUT ~ -1 + SERVICE + MSA + POPLG + POPLG2 + EDULEVEL +
POVERTY + CHIEF + PTCLG + STCLG + PTC2 + STC2 + UNPAVED +
PARTY + TURNOUT, family = binomial(link = "logit"), data = data)
> msummary(M1.c)
Mean St.D. Min Median Max N
OUT 0.269 0.444 0.000 0.000 1.00 10661
SERVICE 8.979 5.141 1.000 9.000 19.00 10661
MSA 0.296 0.456 0.000 0.000 1.00 10661
POPLG 10.265 1.132 7.510 10.071 13.73 10661
Comments
Now I really understand how to do the test assignment I had for statistics. Thank you for showing me that!
Posted by: Google Sniper 2 | March 2, 2011 5:19 PM
Thanks for your advice Karen. I think this could give me an insight to why anyone would want to unfollow me, because for that life of me I can't imagine why that would materialize. I signed up and I'll check again inside of a week or two. Great web page.Ileane recently posted..Matt Cutts Uses WordPress Not Blogger
Posted by: Romaine Zachary | June 1, 2012 1:21 PM
Although the convenience of email cannot be denied, the act of receiving and reading a snailmail letter is by far the better experience. So kudos to you!
I understand that the letters are not personalized, but are they physically signed by the sender? That would be such a pleasant touch and a single for which I'd gladly pay more. Perhaps the sender could sign a small percentage, so that a randomly chosen few every week would use a little extra thrill. That possibility would absolutely make my heart race a bit faster as I tore open the envelope!
Posted by: Myrl Mcardell | June 1, 2012 4:32 PM
Respect above all to job title author, some magic information above all .
Posted by: Blanche Honigsberg | August 26, 2012 4:24 PM
fine&wonderful,I'm not feeling any shivering to see the caterpillar .
How to catch the 6 butterflys side by side.
It is not hard but takes much a longer time. Having said that it is actually a wonderful photograph,if you are interested to know about the butterflys pl.visit the following net backlink.
Posted by: Isabella Pede | September 19, 2012 3:08 AM
Many thanks you guys. This is amazing, already have got a client that I am imagining of implementing this on (in addition to my own blog).
Posted by: Kandace Beierle | September 22, 2012 3:31 AM
Americans are overreachers overreaching is the most admirable of the many American excesses.
Posted by: Lin Guillet | September 25, 2012 5:54 PM
Good Morning to anyone. My Group Is totally from Greece and have a good fresh new net. Visit my website and told me your advice. Yow Will Discover many inspiring ideas and information of my job role. It Is Really absolutely free 100% and without having to registrator. Thanks Much To each and every one which will surf to my fresh internet site. This Will Aid my work. | αυτοκολλητα τοιχου |
Posted by: more information | September 26, 2012 2:35 AM
Very neat blog post.Really thank you! Really Great.
Posted by: Whitney Proescher | September 26, 2012 2:47 AM
...the information knows that individuals are watching and know where by the car is so they are chasing it to get money...you believe the information delay the coverage right until the robbers are caught...information creating news happens the many time
Posted by: Audra Porteus | October 3, 2012 1:41 AM
I am not really good with English but I get hold this very leisurely to interpret.|
Posted by: Blake Rose | October 8, 2012 10:56 AM
I'm still learning from you, as I'm making my way to the top as well. I definitely love reading everything that is posted on your website.Keep the posts coming. I loved it!
Posted by: http://www.negeso.nl/webdesign_nl.html | October 9, 2012 12:05 AM
I always was concerned in this subject and stock still am, thank you for posting.
Posted by: Lachia A | October 10, 2012 4:59 AM
Not my "cup of tea" though the 36 Ford was fun to examine about and glimpse at.
Posted by: Velva Geant | October 20, 2012 1:02 PM
I understood we couldn't go per day without hearing from you. What happened to your score? Are you starting more than hoping for a unique outcome?
Posted by: Christena Rolark | October 28, 2012 9:41 AM
I always was interested in this topic and still am, thank you for putting up.
Posted by: Toys Nudes | October 28, 2012 7:18 PM
I saw a lot of website but I conceive this one has something extra in it. "The free man is he who does not fear to go to the end of his thought." by Leon Blum.
Posted by: david nudes | October 29, 2012 2:49 PM
A short saying oft contains much wisdom.
Posted by: Terence Mcgafferty | October 30, 2012 12:20 AM
Discretion is not the better part of biography.
Posted by: Reed Allyn | October 30, 2012 3:08 AM
Searching for online Christian dating sites in South Africa? Maybe you hope to interact with single African men or African women? Look no further, look at www.christiandating.org.za today!
Posted by: http://www.christiandating.org.za | November 6, 2012 3:31 AM
What a lovely day for a 3415515! SCK was here
Posted by: 3415515 | November 7, 2012 4:27 PM
I like this post, enjoyed this one thanks for putting up. "Good communication is as stimulating as black coffee and just as hard to sleep after." by Anne Morrow Lindbergh.
Posted by: Fredrick Loshe | November 7, 2012 6:14 PM
Champions know that success is inevitable that there is no such thing as failure, only feedback. They know that the best way to
Posted by: Verline Laffin | November 7, 2012 9:38 PM
Exactly what I was looking for, appreciate it for putting up.
Posted by: sponsor | November 12, 2012 9:40 AM
I like your writing style truly enjoying this web site .
Posted by: andrea kropp | November 13, 2012 5:27 AM
It’s hard to find knowledgeable people on this topic, but you sound like you know what you’re talking about! Thanks
Posted by: Bobbi Whigum | November 21, 2012 9:17 PM
Hi Beth Anne,
Thank you for sharing your story with us. The students very much enjoyed your webcast. We look forward to reading your responses to these questions.
Best,
Katie Hoffman
Posted by: Audric | November 23, 2012 4:05 AM
I've been absent for a while, but now I remember why I used to love this web site. Thank you, I will try and check back more often. How frequently you update your site?
Posted by: Edgar Wolner | November 25, 2012 2:57 AM
We have already filled out one of the forms and sent it back in and now you say I have to fill out another one because you haven't received the first one, so I guess when the next one goes in then we will be counted twice. I don't feel that I should have to fill out two and waste the money that the state doesn't have and they have to take away from us stateworkers to get the economy back on their feet. It isn't my problem that your postal services loose our form or can't do their job to get it where it needs to go.
Posted by: Guy | November 25, 2012 9:45 PM
Anyplace in NYC that does not hold the brand "Ray" from the store name.
Posted by: Jolanda Velie | December 6, 2012 2:30 AM
Great site, I really love your writing. Thanks for sharing it with us jamesf1ank@yahoo.com
Posted by: Freddy Dienes | December 7, 2012 12:11 AM
Very interesting subject , appreciate it for posting . "Genius is of no country." by Charles Churchill.
Posted by: atk kantor | December 7, 2012 7:53 PM
What a lovely day for a 2053241! SCK was here
Posted by: 2053241 | December 23, 2012 5:15 PM
It’s remarkable in support of me to have a web site, which is valuable designed for my know-how. thanks admin
Posted by: Bonuses | January 2, 2013 5:03 PM
Laughing usually not feeling like I'm playing by using a total deck as relatives foundation executive director Thanks to the link!
Posted by: Nathanael Runde | January 4, 2013 7:13 PM
Thanks for all your efforts that you have put in this. Very interesting info. "The more I live, the more I think that humor is the saving sense." by Jacob August Riis.
Posted by: YARDANDGARDENONLINE | January 9, 2013 12:29 PM
This is the kind of place I love to see! Succinctly written, it's great!
Posted by: researchchemicals | January 29, 2013 4:52 PM
Dating is a form of courtship consisting of social activities done by two people with the aim of each assessing the other's suitability as a partner in an intimate relationship or as a spouse. While the term has several meanings, it usually refers to the act of meeting and engaging in some mutually agreed upon social activity in public, together, as a couple.
Posted by: Dating Websites | February 2, 2013 9:21 PM
Serious-Globe Methods For philadelphia injury lawyer - A Fast A-Z
Posted by: Full Tort | February 9, 2013 12:02 PM
Thanks for taking the time to write this article. It’s exactly what I was looking for. Truly great post.
Posted by: vigrx plus | February 17, 2013 10:16 PM