Hello to the whole group. I am a newbie to R, but I got my way through and think it is a lot easier to handle than other software packages (far less clicks necessary). However, I have a problem with respect to the summary of regression results. The summary function gives sth like: Residuals: Min 1Q Median 3Q Max -0.46743 -0.09772 0.01810 0.11175 0.42252 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.750367 0.172345 21.761 < 2e-16 *** Var1 -0.002334 0.009342 -0.250 0.802948 Var2 0.012551 0.005927 2.117 0.035444 * Var3 0.015380 0.074537 0.206 0.836730 Var3 0.098602 0.026448 3.728 0.000250 *** ... Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.1614 on 202 degrees of freedom Multiple R-squared: 0.1983, Adjusted R-squared: 0.1506 F-statistic: 4.163 on 12 and 202 DF, p-value: 7.759e-06 However, my wish is the output to have a format like: Estimate (Intercept) 3.750367*** (0.172345) Var1 -0.002334 (0.009342) Var2 0.012551* (0.005927) Etc. so that the standard errors are in parantheses below the estimates. Next to the estimates should be the * indicating significance. I thought that should go by accessing the elements in the summary object, yet, I got started and figured that is quite complicated. Is there a quick and dirty way? Basically I want the same print-out as the summary, except that I don't want the t-statistic and not the p-value, only the significance codes. Thanks a lot in advance Thiemo
On 4/11/2008 12:05 PM, Thiemo Fetzer wrote:> Hello to the whole group. > > I am a newbie to R, but I got my way through and think it is a lot easier to > handle than other software packages (far less clicks necessary). > > However, I have a problem with respect to the summary of regression results. > > The summary function gives sth like: > > Residuals: > Min 1Q Median 3Q Max > -0.46743 -0.09772 0.01810 0.11175 0.42252 > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) 3.750367 0.172345 21.761 < 2e-16 *** > Var1 -0.002334 0.009342 -0.250 0.802948 > Var2 0.012551 0.005927 2.117 0.035444 * > > Var3 0.015380 0.074537 0.206 0.836730 > Var3 0.098602 0.026448 3.728 0.000250 *** > ... > > Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > Residual standard error: 0.1614 on 202 degrees of freedom > Multiple R-squared: 0.1983, Adjusted R-squared: 0.1506 > F-statistic: 4.163 on 12 and 202 DF, p-value: 7.759e-06 > > However, my wish is the output to have a format like: > > Estimate > (Intercept) 3.750367*** > (0.172345) > Var1 -0.002334 > (0.009342) > Var2 0.012551* > (0.005927) > > Etc. so that the standard errors are in parantheses below the estimates. > Next to the estimates should be the * indicating significance. > > I thought that should go by accessing the elements in the summary object, > yet, I got started and figured that is quite complicated. > > Is there a quick and dirty way? > Basically I want the same print-out as the summary, except that I don't want > the t-statistic and not the p-value, only the significance codes.The mtable function in the memisc package by Martin Elff comes pretty close to what you want: library(memisc) (mtable123 <- mtable("Model 1"=lm0,"Model 2"=lm1,"Model 3"=lm2)) Calls: Model 1: lm(formula = sr ~ pop15 + pop75, data = LifeCycleSavings) Model 2: lm(formula = sr ~ dpi + ddpi, data = LifeCycleSavings) Model 3: lm(formula = sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings) ================================================= Model 1 Model 2 Model 3 -------------------------------------------------- Coefficients (Intercept) 30.628*** 6.360*** 28.566*** (7.409) (1.252) (7.355) pop15 -0.471** -0.461** (0.147) (0.145) pop75 -1.934 -1.691 (1.041) (1.084) dpi 0.001 -0.000 (0.001) (0.001) ddpi 0.529* 0.410* (0.210) (0.196) -------------------------------------------------- Summaries R-squared 0.262 0.162 0.338 adj. R-squared 0.230 0.126 0.280 sigma 3.931 4.189 3.803 F 8.3 4.5 5.8 p 0.001 0.016 0.001 Log-likelihood -137.8 -141.0 -135.1 Deviance 726.2 824.7 650.7 AIC 283.7 290.0 282.2 BIC 291.3 297.7 293.7 N 50 50 50 =================================================> Thanks a lot in advance > > Thiemo > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894
Thiemo Fetzer wrote: As a general rule and practical in many contexts uses the following steps: (a) Use the R2HTML library to write the results from the summary to the clipboard (b) Open a spreadsheet and paste the results there. (c) Edit and shove things around until everything are where you want it to be (c) copy and paste things into your document. Tom> Hello to the whole group. > > I am a newbie to R, but I got my way through and think it is a lot easier to > handle than other software packages (far less clicks necessary). > > However, I have a problem with respect to the summary of regression results. > > The summary function gives sth like: > > Residuals: > Min 1Q Median 3Q Max > -0.46743 -0.09772 0.01810 0.11175 0.42252 > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) 3.750367 0.172345 21.761 < 2e-16 *** > Var1 -0.002334 0.009342 -0.250 0.802948 > Var2 0.012551 0.005927 2.117 0.035444 * > > Var3 0.015380 0.074537 0.206 0.836730 > Var3 0.098602 0.026448 3.728 0.000250 *** > ... > > Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > Residual standard error: 0.1614 on 202 degrees of freedom > Multiple R-squared: 0.1983, Adjusted R-squared: 0.1506 > F-statistic: 4.163 on 12 and 202 DF, p-value: 7.759e-06 > > However, my wish is the output to have a format like: > > Estimate > (Intercept) 3.750367*** > (0.172345) > Var1 -0.002334 > (0.009342) > Var2 0.012551* > (0.005927) > > Etc. so that the standard errors are in parantheses below the estimates. > Next to the estimates should be the * indicating significance. > > I thought that should go by accessing the elements in the summary object, > yet, I got started and figured that is quite complicated. > > Is there a quick and dirty way? > Basically I want the same print-out as the summary, except that I don't want > the t-statistic and not the p-value, only the significance codes. > > Thanks a lot in advance > > Thiemo > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
This should be refined, but it gives you a start: .dat<- summary(mod)$coefficients namen <- row.names(.dat) Est <- .dat[,1] Err <- .dat[,2] p <- .dat[,4] p[p<0.0001] <- "***" p[p<0.001] <- "**" p[p<0.01] <- "*" p[p<0.05] <- "." p[p>0.05] <-" " cat(paste(namen,"\t", Est, p, "\n\t\t(",Err,")\n")) Bart Thiemo Fetzer wrote:> > Hello to the whole group. > > I am a newbie to R, but I got my way through and think it is a lot easier > to > handle than other software packages (far less clicks necessary). > > However, I have a problem with respect to the summary of regression > results. > > The summary function gives sth like: > > Residuals: > Min 1Q Median 3Q Max > -0.46743 -0.09772 0.01810 0.11175 0.42252 > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) 3.750367 0.172345 21.761 < 2e-16 *** > Var1 -0.002334 0.009342 -0.250 0.802948 > Var2 0.012551 0.005927 2.117 0.035444 * > > Var3 0.015380 0.074537 0.206 0.836730 > Var3 0.098602 0.026448 3.728 0.000250 *** > ... > > Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > Residual standard error: 0.1614 on 202 degrees of freedom > Multiple R-squared: 0.1983, Adjusted R-squared: 0.1506 > F-statistic: 4.163 on 12 and 202 DF, p-value: 7.759e-06 > > However, my wish is the output to have a format like: > > Estimate > (Intercept) 3.750367*** > (0.172345) > Var1 -0.002334 > (0.009342) > Var2 0.012551* > (0.005927) > > Etc. so that the standard errors are in parantheses below the estimates. > Next to the estimates should be the * indicating significance. > > I thought that should go by accessing the elements in the summary object, > yet, I got started and figured that is quite complicated. > > Is there a quick and dirty way? > Basically I want the same print-out as the summary, except that I don't > want > the t-statistic and not the p-value, only the significance codes. > > Thanks a lot in advance > > Thiemo > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >-- View this message in context: http://www.nabble.com/Format-regression-result-summary-tp16636200p16698297.html Sent from the R help mailing list archive at Nabble.com.
On Fri, Apr 11, 2008 at 11:05 AM, Thiemo Fetzer <tf at devmag.net> wrote:> Hello to the whole group. > > I am a newbie to R, but I got my way through and think it is a lot easier to > handle than other software packages (far less clicks necessary). >[snip]> However, my wish is the output to have a format like: > > Estimate > (Intercept) 3.750367*** > (0.172345) > Var1 -0.002334 > (0.009342) > Var2 0.012551* > (0.005927) > > Thanks a lot in advance > > Thiemo >I attach an R function "outreg" that can make nice looking regression tables in various formats. I was thinking about writing something for R news about this, but stopped to wait because I could not figure a way to get lmer objects to print out in some pleasant way. I have several students and colleagues who use this, no problem lately. This pdf demonstrates some of the kinds of output it can create. http://pj.freefaculty.org/R/outreg-worked2.pdf The R code here is not pretty, I'm obviously trying to do things that are not anticipated by the original developers. I found it a bit tedious to do output with "cat" and so forth, but never found a more elegant way. If anybody wants to help with beautifying the code, please give me some pointers. -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas