# Confidence interval estimation in easy to understand way

I want to understand well estimation of the confidence intervals.

If I perform the estimation of confidence interval this way:

margin of error = standard error * zscore from table below

lower bound of confidence interval = estimate of the test - the margin of error

upper bound of confidence interval = estimate of the test + the margin of error

CI zscore
0.75 1.15
0.85 1.44
0.95 1.96

Questions:

1. Can I get the confidence interval for any statistical test with the way described above?
2. By using zscore corresponding to the confidence interval in the table above will I get right confidence interval?
3. Does the confidence intervals estimated that is described above is called Wald confidence interval? If not, what is the right name of that type of confidence intervals?

Confidence intervals for the mean $$\mu$$ of a normal population based on a random sample of size $$n$$ from the population are of the type you mention.

• A 95% z-interval, if the population standard deviation $$\sigma$$ is known is of the form $$\bar X \pm 1.96\,\sigma/\sqrt{n}.$$ where $$\bar X$$ is the sample mean and $$\sigma/\sqrt{n}$$ is called the _standard error of the mean.

• A 95% t-interval, if $$\sigma$$ is unknown and estimated by the sample standard deviation $$S,$$ is of the form $$\bar X \pm t^*\,S/\sqrt{n},$$ where $$t^*$$ cuts probability $$0.025$$ from the upper tail of the (symmetrical) Student distribution with $$n-1$$ degrees of freedom, and $$S/\sqrt{n}$$ is the (estimated) standard error of the mean.

Consider the following sample of size $$n = 50$$ from $$\mathsf{Norm}(\mu,\sigma).$$ (Using R for sampling and computation.)

set.seed(2022)
x = rnorm(50, 100, 15)
mean(x)
 98.06686


Then the z-interval for $$\mu,$$ where we know $$\sigma=15$$ is $$(93.9,\,102.2):$$

CI = mean(x) + qnorm(c(.025,.975)*\15/\sqrt{50}
  93.90915 102.22457


By contrast, the t-interval for $$\mu,$$ where $$\sigma$$ is estimated by $$S$$ is $$(94.34,\, 101.790).$$ The t.test procedure in R makes this interval. You can verify if for yourself, using the formula above.

t.test(x)$conf.int  94.34387 101.78984 attr(,"conf.level")  0.95  However, for various populations other than normal and population parameters other than $$\mu,$$ confidence intervals for various population parameters may be of different styles. Here are examples of yet other styles of CIs that do not explicitly use endpoints based on a margin of error (based on standard error) above and below the sample mean CI for normal variance. The confidence interval for the variance $$\sigma^2$$ of a normal population is based on the fact that $$\frac{(n-1)S^2}{\sigma^2} \sim \mathsf{Chisq}(\nu=n-1).$$ The CI is of the form $$\left(\frac{(n-1)S^2}{U},\frac{(n-1)S^2}{L}\right),$$ where $$L$$ and $$U$$ cut probability $$0.025$$ from the lower and upper tails, respectively, of $$\mathsf{Chisq}(n-1).$$ The 95% CI for $$\sigma^2$$ is $$(119.7,\,266.5).)$$ Notice that the point estimate $$\widehat{\sigma^2} = 171.6.$$ does not lie at the center of this CI (because the chi-squared distribution is not symmetrical). Take square roots of the endpoint of the CI for $$\sigma^2$$ to get a 95% CI $$(10.84,\,16.32)$$ for the population standard deviation $$\sigma.$$ var(x)  171.6105 49*var(x)/qchisq(c(.975,.025), 49)  119.7469 266.4851 sqrt(49*var(x)/qchisq(c(.975,.025), 49))  10.94289 16.32437  Bootstrap CI for gamma mean. The population distribution $$\mathsf{Gamma}(\mathrm{shape}=3,\mathrm{rate}=0.2)$$ has mean $$\mu = 3/0.2 = 15.$$ There ere theoretical CIs for $$\mu$$ based on estimates of parameters (the shape and rate) of such a distribution, but the formulas are not as simple as the ones we have seen above. Moreover, in a real application, if we have a sample of size $$n = 500$$ from a population with this distribution, we may not even know that the population is gamma distributed. Then a 95% nonparametric bootstrap CI can give useful information. Here is how one style of bootstrap CI can be computed. By repeated re-sampling with replacement from the sample, we can get an idea of the variability of $$\bar X$$ as a point estimate of $$\mu$$ and use that information to make a 95% CI $$(4.28,\, 15.74)$$ for $$\mu.$$ # simulate fictitious gamma data set.seed(519) y = rgamma(500, 3, 1/5) summary(y); sd(y) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.3141 8.4593 13.1476 14.9594 19.4401 52.2321  8.913885 # 95% nonparametric bootstrap CI set.seed(1234) a.obs = mean(y) d = replicate(200, mean(sample(y,500,rep=T))-a.obs) UL = quantile(d, c(.975,.025)) a.obs - UL 97.5% 2.5% 14.27896 15.74119  • Thank you so much for detailed explanation, especially providing R code. Could you also please provide direct answers to three questions that are in my post? That way it will be much easier for me to understand. Thank you so much for your answer! May 19 at 22:07 • (1) No. I showed CIs for normal dist'n$\sigma^2$and gamma dist'n$\mu\$ in my Answ specifically to show that not all intervals are of the type you describe. (2) Yes. Numbers in table are approx. correct for the z intervals mentioned, (3) "Wald interval" is most often used to refer to CIs for binomial and other proportions. Sometimes "Wald interval" is incorrectly used to refer to almost any kind of CI that is asymptotically correct (works best for very large sample sizes). // These three questions do not seem directly related to other issues in your posted question. May 20 at 6:11
• Thank you so much for you detailed explanations and answers. May 20 at 16:18