[R] Call the Standard Error and t-test probability in linear regression
Martin Maechler
maechler at stat.math.ethz.ch
Fri Mar 2 14:30:13 CET 2012
> 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.
indeed.
> Hence
> summary(lm.r)$coef
> would give the full 4x4 matrix (you can abbreviate "coefficients"
> to "coef"),
Yes. In the present case, I tell all my "students" (:= everyone
who wants to learn .. ;-) to use
coef(summary(lm.r))
instead of
summary(lm.r)$coef
because using the coef() [or coefficients()] method will work
with many more models and situations, notably also for cases
where the (summary of the) fitted model is not a list (but e.g. a S4 class,
reference class, ..), or does not store these in exactly this location.
Martin
> 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
> ______________________________________________
> 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.
More information about the R-help
mailing list