Chi-squared confidence interval for variance

When constructing, for example, a $$90\%$$ confidence interval for the population variance using the chi-squared distribution, we have:

\begin{align} & P\left(a<\frac{(n-1)S^2}{\sigma^2}

In my course, we then find $$a, b$$ such that $$P(\chi_{n-1}^{2}b)=0.05.$$

My question is, given that the chi-squared distribution is asymmetric for small $$n,$$ why do we pick $$0.05$$ for both sides? Surely we’d have a shorter confidence interval if we weighted more of the $$0.1$$ probability to one of the sides, instead of splitting equally?

Because the chi-squared distribution is skewed, the sample variance is not generally at the center of a 95% CI for the variance (for normal data).

You are correct to say that you can often get a narrower interval by taking something like probability 2% from one tail and 3% from the other, than by taking 2.5% from each tail.

For practical purposes, the narrowest 95% interval may put almost all of the 5% probability in one tail, thus becoming nearly a one-sided interval. This may or may not be useful.

Thus, it has become more or less standard to use probability-symmetric intervals in general practice. If you are not showing a probability-symmetric interval, it is a good idea to report that you are not, and to explain why.

Example: Consider a normal sample of size $$n=20$$ with variance $$\sigma^2 = 25.$$

set.seed(2022)
x = rnorm(20, 50, 5)
v = var(x);  v
[1] 25.01484


Seven 2-sided 95% CIs for $$\sigma^2$$ and their widths:

CI.1 = 19*v/qchisq(c(.97, .02), 19)
CI.1; diff(CI.1)
[1] 14.77971 55.47799
[1] 40.69828

CI.2 = 19*v/qchisq(c(.975, .025), 19)
CI.2; diff(CI.2)
[1] 14.46722 53.36339
[1] 38.89617    # probability-symmetric

CI.3 = 19*v/qchisq(c(.98, .03), 19)
CI.3; diff(CI.3)
[1] 14.10859 51.65860
[1] 37.55002

CI.4 = 19*v/qchisq(c(.99, .04), 19)
CI.4; diff(CI.4)
[1] 13.13265 49.00681
[1] 35.87417

CI.5 = 19*v/qchisq(c(.995, .045), 19)
CI.5; diff(CI.5)
[1] 12.31867 47.93333
[1] 35.61466   # shortest on this list

CI.6 = 19*v/qchisq(c(.999, .049), 19)
CI.6; diff(CI.6)
[1] 10.84618 47.16119
[1] 36.31501   # longer than above

CI.7 = 19*v/qchisq(c(.99999, .04999), 19)
CI.7; diff(CI.7)
[1]  8.284141 46.980289
[1] 38.69615   # 'almost' one sided


Note: The relevant one-sided 95% CI would give the upper bound $$46.97848.$$ Depending on the application, that might be exactly what you want.

• Just as a useful observation for readers, it is worth noting that the shortest CI found here (the interval $[12.31867, 47.93333]$) is indeed close to the optimal CI computed using the optimisation method in the CONF.var function in the stat.extend package (see other answer here). So this method gets very close to the optimal CI (and obviously you could keep iterating to get as close as you want if desired).
– Ben
Commented Feb 26, 2022 at 23:22

For univariate continuous asymmetric distributions the highest density region (HDR) can be found by solving a constrained optimisation problem for the boundary points. You are correct that this involves placing non-equal weight in the tails. You can find a detailed analysis of this problem in O'Neill (2021), including a statement of the optimisation problem at issue and its solution. This paper also goes through the problem of finding the optimal confidence interval for the variance.

To save you from reinventing the wheel, it is worth noting that HDRs for all standard univariate distributions are available in the stat.extend package in R. The available families include the chi-squared distribution, the gamma distribution, and the inverse gamma distribution. These can be used to manually compute the optimal confidence interval. Alternatively, there are also direct functions for optimal confidence intervals, including the optimal confidence interval for the variance. In the code below we use the CONF.var function to compute the optimal 95% confidence interval for some mock data.

#Load library
library(stat.extend)

#Create some mock data (same data as used by BruceET)
set.seed(2022)
x = rnorm(20, 50, 5)

#Compute optimal confidence interval
#Assumes a mesokurtic distribution (kurt = 3)
CONF.var(x, alpha = 0.05, kurt = 3)

Confidence Interval (CI)

95.00% CI for variance parameter for infinite population
Interval uses 20 data points from data x with sample variance = 25.0148 and
assumed kurtosis = 3.0000
Computed using nlm optimisation with 8 iterations (code = 1)

[12.4006846357447, 48.0126609150707]


$$\Pr(a<\chi^2_k

One way to choose $$a$$ and $$b$$ is to choose them so that the values of the chi-square density function at those two points are equal to each other, and at the same time so that line $$(1)$$ above is true.

That does give you a shorter confidence interval, but it is numerically somewhat complicated to implement, and probably the purpose in the course you're taking is just to show that it is possible to get a confidence interval for $$\sigma^2$$ by "inverting" the "pivotal quantity" $$(n-1)S^2/\sigma^2.$$

• By "inverting" above, I refer to an inverse-function, i.e. you solve the system of inequalities $a<(n-1)S^2/\sigma^2<b$ for $\sigma^2.$ "Pivotal" means its probability distribution does not depend on unobservables such as $\sigma^2$ (or $\mu,$ if that is the population mean). The random variable $(n-1)S^2/\sigma^2$ does depend on $\sigma,$ (so it is not a statistic) but its probability distribution doesn't. (Pivotal quantities should not be confused with ancillary statistics, whose probability distribution does not depend on unobservables, but which are observable.) $\qquad$ Commented Feb 20, 2022 at 18:41

One answer is why not use equal probabilities for both tails? Suppose we do not, we then produce asymmetric confidence intervals in terms of probability. Let us take an extreme example, to make a 95% confidence interval, we would usually set the interval at 2.5% lower, and 2.5% upper tail. Now we decide we want an extreme example, so we choose 0% left tail and a 5% upper-tail of a heavy right tailed distribution. What is that? It is a 5% one-tailed (right) answer to the question of what the probability is of an $$X_i\geq$$ the larger confidence interval upper bound. So, why balance the probabilities? So that the probability of an answer lower than the confidence interval is the same the probability of an answer higher than the confidence interval, which then gives us a balanced or two-tailed answer, which is the probability of a $$X_i\neq$$ a value within the confidence interval.

It is not unreasonable to ask if there are situations in which one wants unequal probabilities for the tails. Here is an arbitrary example for which the probabilities are not the final answers sought. Suppose that the x-axis measure is a length of pipe that we have produced by cutting very long pipes in a factory, and let us further suppose that if a pipe is too short (i.e., less than our hypothetical confidence interval lower bound) we must discard it and that costs twice as much as a pipe that is too long, which too long pipe can be sent back for trimming to length. In that case, we might want a left tail that is half as probable as a right tail in order to balance the cost of having pipes of the wrong length.