[R] Extract information from the summary of 'lm'

Jun Ding dingjun_cn at yahoo.com
Wed Jun 21 04:25:02 CEST 2006


Hi Everyone, 

I just don't know how to extract the information I
want from the summary of a linear regression model
fitting. 

For example, I fit the following simple linear
regression model: 

results = lm(y_var ~ x_var)

summary(results) gives me:

Call:
lm(formula = y_var ~ x_var)

Residuals:
    Min      1Q  Median      3Q     Max 
-5.9859 -1.5849  0.4574  2.0163  4.6015 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  -1.7782     0.5948  -2.990 0.004879 ** 
x_var         2.1237     0.5073   4.187 0.000162 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.'
0.1 ' ' 1 


I can get the esitmates (i.e. -1.7782 and 2.1237) of
coefficients by calling

results$coefficients

But I don't know how to get the corresponding t values
and P values for those coefficients. I am running a
lot of regression models and I can not run 'summary'
every time to get the t and P values for each model.

Can anybody give me some hints? Thank you very much!

Best,

Jun

----------------------------
Jun Ding, Ph.D. student
Department of Biostatistics
University of Michigan
Ann Arbor, MI, 48105



More information about the R-help mailing list