# Doubt in derivation of expectation of sample variance

Here in evaluation of expectation $$E[\frac{(n-1)S^2}{\sigma^2}]$$, why $$\sigma^2$$(population variance) is treated as constant?. What to consider a constant and what as variable, and how to differentiate which is considered which?

My thinking - We do not know population variance $$\sigma^2$$. So we come up with some sample and calculate its sample variance and try to see that it is closest estimate of population variance. But when we treat $$\sigma^2$$ as a known constant(it means it's an already known value?), then why again are we calculating sample variance.

pardon me for the silly question.

Another doubt - why in sample variance we are considering $$1/(n-1)$$ and in population variance $$1/n$$. When we take sample size n large enough i.e. n tends to infinity, doesn't n and n-1 mean just the same?

Why $$\sigma^2$$ (population variance) is treated as constant?.

The fact that $$\sigma^2$$ is treated as a constant does not imply that it is known. It is there, static, but unknown to us. All we can do is estimate it using sample.

To demonstrate it's a static value, suppose that we are able to collect all of population and calculate its variance. The value of $$\sigma^2$$ will always stay the same no matter how many times we do it.

This is different from sample variance, because when we take samples randomly from the population, the sample variance $$s^2$$ can be different from one set of samples to another. Hence $$s^2$$ is treated as a variable and $$\sigma^2$$ is treated as a constant.

Regarding $$n$$ vs $$n-1$$ as denominator, you can work it out using exactly that expectation notation to arrive at a conclusion that using $$\frac{1}{n}$$ in sample variance results in a biased expectation $$E(\hat{\sigma^2}) \neq \sigma^2$$.

• thank you sir, this clarified my doubt. Missed it. Yesterday did not open stackexchange. – Nascimento de Cos Jul 20 '20 at 9:29

In finding the distribution under the null hypothesis $$H_0,$$ you need to include the assumptions of the test and the parameter value specified by $$H_0.$$ Then you compare a statistic from your data to compare with the 'null' distribution. I agree with @Nuclear03020704's answer (+1), and take a more computational approach here.

In your example, the data are assumed normal with unknown population mean $$\mu$$ (estimated from data by $$\bar X)$$ and $$\sigma^2$$ (estimated from data by $$S^2).$$

In your link, you are told that $$\frac{(n-1)S^2}{\sigma^2}\sim\mathsf{Chisq}(\nu=n-1).$$ Then because the mean of a chi-squared random variable, with DF $$n-1,$$ is $$n-1,$$ So $$E\left(\frac{(n-1)S^2}{\sigma^2}\right)$$ = $$n-1$$ so $$\frac{n-1}{\sigma^2}E(S^2)= n-1,\;$$ and $$E(S^2) = \sigma^2.$$

All of this is hypothetical until you get data. Then if you have $$n=20$$ observations with $$S^2=\frac{1}{n-1}(X_i-\bar X)^2 = 35.21,$$ do you believe it is possible that the true value of $$\sigma^2 = 30?$$ You test $$H_0:\sigma^2 = 30$$ against $$H_a: \sigma^2 \ne =30$$ at the 5% level.

You know that $$P\left(L \le \frac{(n-1)S^2}{\sigma_0^2} \le U\right)= P\left(\frac{\sigma_0^2L}{n-1} \le S^2 \le \frac{\sigma_0^2U}{n-1} \right)=0.95,$$

where $$L$$ and $$U$$ cut 2.5% from the lower and upper tails, respectively, of the distribution $$\mathsf{Chisq}(19),$$ and from $$H_0$$ you get $$\sigma^2_0 = 30.$$ You can find $$L$$ and $$U$$ in printed tables of chi-squared distributions or by using R, as below.

L = qchisq(.025, 19);  U = qchisq(.975, 19)
L
[1] 8.906516
U
[1] 32.85233
L*30/19; U*30/19
[1] 14.06292    # lower critical value
[1] 51.8721     # upper critical value


Thus, $$P(11.06 < S^2 < 51.87) = 0.95$$ and the left and right critical values of the test statistic $$S^2$$ are 11.06 and 51.87. Because $$S^2 = 35.21$$ lies between these critical values, you cannot reject $$H_0.$$

Here is a simulation in R, in which we find the sample variances v of a million samples of size $$n=20$$ sampled from $$\mathsf{Norm}(mu=100, \sigma_0=\sqrt{30}).$$ We see what fraction of them lie outside the critical values. That is the significance level 5% of the test. The result is very close to 5%.

set.seed(2020)
v = replicate( 10^6, var(rnorm(20, 100, sqrt(30))) )
mean(v <= 14.06 | v >= 51.87)  # | means OR
[1] 0.04976


Also, we can compare a histogram of the million values of $$(n-1)S^2/30 = 19S^2/30$$ with the density curve of $$\mathsf{Chisq}(19).$$

q = 19*v/30
hist(q, prob=T, br=30, col="skyblue2", main="")