# Extract standard errors of coefficient linear regression R [duplicate]

Possible Duplicate:
How do I reference a regression model's coefficient's standard errors?

If I have a dataset:

data = data.frame(xdata = 1:10,ydata = 6:15)


and I run a linear regression:

fit = lm(ydata~.,data = data)
out = summary(fit)

Call:
lm(formula = ydata ~ ., data = data)

Residuals:
Min         1Q     Median         3Q        Max
-5.661e-16 -1.157e-16  4.273e-17  2.153e-16  4.167e-16

Coefficients:
Estimate Std. Error   t value Pr(>|t|)
(Intercept) 5.000e+00  2.458e-16 2.035e+16   <2e-16 ***
xdata       1.000e+00  3.961e-17 2.525e+16   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.598e-16 on 8 degrees of freedom
Multiple R-squared:     1,  Adjusted R-squared:     1
F-statistic: 6.374e+32 on 1 and 8 DF,  p-value: < 2.2e-16


How do I extract the standard errors of the regression coefficients from either fit or out? I can't seem to figure it out. Thanks!

-

## marked as duplicate by chl♦May 2 '12 at 10:54

It's useful to see what kind of objects are contained within another object. Using names() or str() can help here.

names(out)
str(out)


The simplest way to get the coefficients would probably be:

out\$coefficients[ , 2] #extract 2nd column from the coefficients object in out

-
fit = lm(data ~ .,data = data)

These are the classical asymptotic ones you see in summary. Please also see the links in my answer to this same question about alternative standard error options.