[R] Format regression result summary
Chuck Cleland
ccleland at optonline.net
Fri Apr 11 18:18:40 CEST 2008
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
More information about the R-help
mailing list