Constructing 90% confidence interval for standard deviation on Matlab

852 Views Asked by At

I'm currently working on my dissertation and require calculating confidence interval on matlab. I learnt that when the underlying population follows a normal distribution, the confidence intervals for standard deviation and variance follow chi-square distribution. However, when trying to construct the C.I. (for Variance and SD) on matlab, i'm not sure whether matlab used the chi-square distribution. I obtained the S.D. of GDP and GDI (two variables i use), calculated their ratio - (SD of GDP)/(SD of GDI) and named the result 'Phi'.

The code i used is:

pdgdp = fitdist(gdp,'Normal')

ci = paramci(pdgdp,'Alpha',0.1)

Can someone please clarify whether Matlab used the chi-square distribution to compute confidence interval for standard deviation? Also, I need to compute a 90% confidence interval for 'Phi' on matlab. May i please request help for this as well?

Thanks in advance

1

There are 1 best solutions below

2
On

Suppose you have a random sample $X_1, X_2, \dots. X_n$ from a normal population with unknown mean $\mu$ and unknown variance $\sigma^2.$ Then the sample variance $$S^2 = \frac{1}{n-1} \sum_{i=1}^n (X_i - \bar X)^2$$ is used to estimate $\sigma^2.$ You have

$$Q = \frac{(n-1)S^2}{\sigma^2} \sim \mathsf{Chisq}(n-1),$$

the chi-squared distribution with $n-1$ degrees of freedom. Find numbers $L$ and $U$ which cut probability 2.5% from the lower and upper tails, respectively, of $\mathsf{Chisq}(n-1).$

Then

$$0.95 = P(L \le Q \le U) = P\left(\frac 1U \le \frac{\sigma^2}{(n-1)S^2} \le \frac 1L\right)\\ P\left(\frac{(n-1)S^2}{U}\le \sigma^2 \le\frac{(n-1)S^2}{L}\right),$$ so that a 95% confidence interval for $\sigma^2$ is of the form $$\left(\frac{(n-1)S^2}{U},\;\frac{(n-1)S^2}{L}\right)$$ and a 95% confidence interval for the population standard deviation $\sigma$ is of the form $$\left(\sqrt{\frac{(n-1)S^2}{U}},\;\sqrt{\frac{(n-1)S^2}{L}}\right).$$

You do not need to use Matlab in order to construct such a confidence interval for $\sigma,$ although using Matlab as a calculator may be convenient.

Suppose a normal sample of size $n = 10$ has $S = 3.75.$ Then use software or printed chi-squared tables to find $L = 2.700$ and $U = 19.023.$ In R statistical software, the computation looks like this:

qchisq(c(.025,.975), 9)
[1]  2.700389 19.022768
  • If using tables, look at the row for DF = 9, and notice the notation that is used for the column headers where the appropriate numbers are listed. You can use this particular example to get used to reading printed tables.

  • If using Matlab, you need to find out how to compute the 'inverse CDF' or 'quantile function' of a chi-squared distribution.

Whether you use Matlab or printed tables and a hand calculator, you can verify that a 95% confidence for $\sigma$ in this particular example is $(2.579, 6.846).$ Notice that $S = 3.75$ is contained in this confidence interval, even though it is not exactly at the center of the interval.

sqrt(9*3.75^2/qchisq(c(.975,.025), 9))
[1] 2.579382 6.846038

Note: For confidence intervals based on the (symmetrical) standard normal and Student t distributions, the point estimate $\bar X$ of $\mu$ is at the center of the confidence interval for $\mu.$ However, chi-squared distributions are not symmetrical.