# How to find residual variance of a linear regression model in R?

## Example

x2<-rpois(5000,5)
y2<-rpois(5000,2)
Model2<-lm(y2~x2)
summary(Model2)

## Call

lm(formula = y2 ~ x2)

## Residuals

  Min 1Q Median 3Q Max
-2.0474 -0.9898 0.0030 1.0102 6.0318

## Coefficients

Estimate Std. Error t value Pr(>|t|) (Intercept) 1.953861 0.049840 39.203 <2e-16 *** x2 0.007192 0.009125 0.788 0.431 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error − 1.423 on 4998 degrees of freedom

Multiple R-squared − 0.0001243, Adjusted R-squared: -7.578e-05

F-statistic − 0.6212 on 1 and 4998 DF, p-value: 0.4306

## Example

x4<-rexp(100000,5.5)
y4<-rexp(100000,7.5)
Model4<-lm(y4~x4)
summary(Model4)

## Call

lm(formula = y4 ~ x4)

## Residuals

  Min 1Q Median 3Q Max
-0.13359 -0.09515 -0.04089 0.05144 1.39856

## Coefficients

Estimate Std. Error t value Pr(>|t|) (Intercept) 0.1335960 0.0005972 223.697 <2e-16 *** x4 -0.0010954 0.0023153 -0.473 0.636 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error − 0.1335 on 99998 degrees of freedom

Multiple R-squared − 2.239e-06, Adjusted R-squared : -7.762e-06

F-statistic − 0.2239 on 1 and 99998 DF, p-value: 0.6361

 6.604745