4
$\begingroup$

Consider the following data and the model:

y <- c(9,3,-2,7,6,12)
lm(y~-1)

summary(lm(y~-1))$sigma^2
[1] 53.83333

I expected var(y) will give the same result of summary(lm(y~-1))$sigma^2. But, it did not give, rather mean(y^2) gave same result? Isn't formula of mean(y^2) is $\frac{\sum_{i=1}^{n}y_i^2}{n}$? Why are the results of summary(lm(y~-1))$sigma^2 and mean(y^2) same?

var(y)
[1] 23.76667

mean(y^2)
[1] 53.83333
$\endgroup$

2 Answers 2

7
$\begingroup$

If you define the model as lm(y~1), you will get a value of 23.76667 for sigma^2.

Your model does not have an intercept (that's the -1 in the formula), which is equivalent to stating that the y values come from a population with mean zero. Your estimate of the population variance is, thus, $\frac{\sum_{i=1}^{n}y_i^2}{n}$.

$\endgroup$
0
4
$\begingroup$

summary(lm(y~-1))$sigma^2 gives the variance of the residuals from your model, but your model is one that doesn't fit any parameters and just predicts $0$ every time: $\hat y_i = 0\space\space\forall\space\space i$. There are no parameters estimated from the data. Therefore, the residuals are the $y$-values themselves, and their variance is calculated assuming a degrees of freedom equal to the sample size itself (you don't lose a degree of freedom estimating the mean).

$$ \text{var}\left(\hat\varepsilon\right) = \dfrac{\sum_i y_i}{N} $$

This is exactly the identity you observe.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.