# Get error value from linear regression function lm

I have a linear regression problem that I solved with:

``````m=lm(value ~ mean, data=d)
```

```

and from this value i you can get R2 and the regression equation.

but I want to get a standard error (installation error). i was able to see the value, but i don't know how to get it to store it in the dataframe.

I get the value using `summary(m)`

and the result looks something like this:

``````Call:
lm(formula = value ~ mean, data = d)

Residuals:
Min      1Q  Median      3Q     Max
-25.000 -15.909  -2.124  14.596  44.697

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)  2.500e+01  1.064e+00   23.49   <2e-16 ***
mean        -1.759e-06  1.536e+00    0.00        1
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 16.85 on 1298 degrees of freedom
Multiple R-squared: 1.01e-15,   Adjusted R-squared: -0.0007704
F-statistic: 1.311e-12 on 1 and 1298 DF,  p-value: 1
```

```

so the question is, how can I access these values?

Thank you

+3

source to share

The function `summary`

simply returns a list R.

``````##Generate some dummy data
x = runif(10);y = runif(10)
m = summary(lm(y ~ x))
```

```

We can use the normal list syntax to retrieve what we want. For example,

``````m[[4]]
```

```

Returns the model data frame fits

``````R> m[[4]]
Estimate Std. Error t value Pr(>|t|)
(Intercept)  0.44265     0.2443  1.8123   0.1075
x            0.07066     0.4460  0.1584   0.8781
```

```

and `m[[6]]`

returns`Residual standard error`

``````R> m[[6]]
[1] 0.2928
```

```

There are several handy functions such as `coefficients(m)`

+8

source

Access to balances using `resid(m)`

.

EDIT: From the comments, it sounds like what you want `sum(resid(m) ^ 2)`

.

+2

source

Extract residual standard deviation "Sigma"

``````sigma(m)
```

```
0

source

All Articles