user1871869
user1871869

Reputation: 3367

Get variables from summary?

I want to grab the Standard Error column when I do summary on a linear regression model. The output is below:

         Estimate Std. Error z value Pr(>|z|)    
(Intercept) -8.436954   0.616937 -13.676  < 2e-16 ***
x1          -0.138902   0.024247  -5.729 1.01e-08 ***
x2           0.005978   0.009142   0.654  0.51316    `
...

I just want the Std. Error column values stored into a vector. How would I go about doing so? I tried model$coefficients[,2] but that keeps giving me extra values. If anyone could help that would be great.

Upvotes: 0

Views: 695

Answers (1)

jlhoward
jlhoward

Reputation: 59345

Say fit is the linear model, then summary(fit)$coefficients[,2] has the standard errors. Type ?summary.lm.

fit <- lm(y~x, myData)
summary(fit)$coefficients[,1]   # the coefficients
summary(fit)$coefficients[,2]   # the std. error in the coefficients
summary(fit)$coefficients[,3]   # the t-values
summary(fit)$coefficients[,4]   # the p-values

Upvotes: 1

Related Questions