Call the Standard Error and t-test probability in linear regression
On 02-Mar-2012 IOANNA wrote:
Hello, I run a linear regression I get the summary, e.g.:
Call:
lm(formula = signal ~ conc)
Residuals:
1 2 3 4 5
0.4 -1.0 1.6 -1.8 0.8
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.60000 1.23288 2.92 0.0615 .
conc 1.94000 0.05033 38.54 3.84e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.592 on 3 degrees of freedom
Multiple R-Squared: 0.998, Adjusted R-squared: 0.9973
F-statistic: 1486 on 1 and 3 DF, p-value: 3.842e-0
I would like to call the probability of the t-test only in order
to use it separately. For example I 'd like to get:
Pr<-3.84e-05
Similarly I want to call the standard error of the parameters
and the function:
SEconc<-0.05033
I don't know how to do this. Any help?
Regards,
Ioanna
Hi Ioanna,
If you look at '?summary.lm' and read the section "Value",
you will see that the returned value is a list with several
components, one of which is:
coefficients: a p x 4 matrix with columns for the
estimated coefficient, its standard error,
t-statistic and corresponding (two-sided) p-value.
Aliased coefficients are omitted.
This is effectively as displayed by summary(lm...)).
So your
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.60000 1.23288 2.92 0.0615 .
conc 1.94000 0.05033 38.54 3.84e-05 ***
(apart from the significance codes "." and "***") are the elements in this p=2 x 4 matrix. Hence summary(lm.r)$coef would give the full 4x4 matrix (you can abbreviate "coefficients" to "coef"), and so summary(lm.r)$coef[2,4] will give you the P-value for "conc", and summary(lm.r)$coef[2,2] will give the SE of the estimate of "conc". And so on. Ted. ------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at wlandres.net> Date: 02-Mar-2012 Time: 13:09:03 This message was sent by XFMail