[R] How to Extract Std.Error

Douglas Bates bates at stat.wisc.edu
Thu Oct 30 20:06:26 CET 2003


Thomas Petzoldt <petzoldt at rcs.urz.tu-dresden.de> writes:

> umeno wrote:
> 
> > I would like to know if anyone has any idea of how to extract
> > Std.Error from the regression output.  I know how to extract
> > coefficients, but I could not figure out how to retrieve
> > std. error...
> 
> 
> Given a model like this
> 
> model <- lm(y~x)
> 
> first analyse the data structure of the summary() with
> 
> str(summary(model))
> 
> looking into this, the following (or something similar for the other
> values) should work:
> 
> summary(reg)$coefficients[,2]

It would be better form to use
  coef(summary(reg))[, 2]
or even
  coef(summary(reg))[, "Std. Error"]

It is safer to use extractor functions like coef() than to rely on the
object returned by summary having components with particular names.




More information about the R-help mailing list