0

I'm trying to store the standard errors from some regressions I ran in R.

I already know that when storing the coefficients I can just go: beta1 <- coefficients(regression)["x"]

But how would I replicate this for the standard errors in the same regression?

  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Oct 25 '21 at 21:31

1 Answers1

2

The standard errors are part of the object returned by summary:

# make a reproducible example
x <- 1:10
y <- 2*x + 5 + rnorm(x)

# fit model
m <- lm(y ~ x)

summary_obj <- summary(m) # store summary in an object
summary_obj               # contains the table with the standard errors

str(summary_obj) # shows the structure of the summary object

stderrs <- summary_obj$coefficients[,2] # get stderrs from column 2
stderrs
tpetzoldt
  • 5,338
  • 2
  • 12
  • 29