View Zhirong Zhao's profile on LinkedIn

Blogroll

My pages

Visitors

Powered by

Header image of Hong Kong financial center courtesy of hleung on flickr.

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!

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

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!

Respect above all to job title author, some magic information above all .

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.

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).

Americans are overreachers overreaching is the most admirable of the many American excesses.

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. | αυτοκολλητα τοιχου |

Very neat blog post.Really thank you! Really Great.

...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

I am not really good with English but I get hold this very leisurely to interpret.|

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!

I always was concerned in this subject and stock still am, thank you for posting.

Not my "cup of tea" though the 36 Ford was fun to examine about and glimpse at.

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?

I always was interested in this topic and still am, thank you for putting up.

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.

A short saying oft contains much wisdom.

Discretion is not the better part of biography.

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!

What a lovely day for a 3415515! SCK was here

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.

Champions know that success is inevitable that there is no such thing as failure, only feedback. They know that the best way to

Exactly what I was looking for, appreciate it for putting up.

I like your writing style truly enjoying this web site .

It’s hard to find knowledgeable people on this topic, but you sound like you know what you’re talking about! Thanks

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

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?

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.

Anyplace in NYC that does not hold the brand "Ray" from the store name.

Great site, I really love your writing. Thanks for sharing it with us jamesf1ank@yahoo.com

Very interesting subject , appreciate it for posting . "Genius is of no country." by Charles Churchill.

What a lovely day for a 2053241! SCK was here

It’s remarkable in support of me to have a web site, which is valuable designed for my know-how. thanks admin

Laughing usually not feeling like I'm playing by using a total deck as relatives foundation executive director Thanks to the link!

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.

This is the kind of place I love to see! Succinctly written, it's great!

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.

Serious-Globe Methods For philadelphia injury lawyer - A Fast A-Z

Thanks for taking the time to write this article. It’s exactly what I was looking for. Truly great post.

Hubert H. Humphrey Institute of Public Affairs