Constructing Confidence Interval
This notebook explores methods of constructing Confidence Intervals. We focus on the following methods:
- Exact calculation
- CLT CI
- Hoeffding CI
- Plug-in (Wald) CI
- Wilson score CI
We focus on the example of estimating the mean of a Bernoulli distribution with parameter .
Test Statistic and Critical Values
Recall that a Statistic is a function of the observed data, e.g., mean and variance. If a test involves some parameters, a test statistic is often a function of both the sample and the parameter, such that
- the distribution of is known, e.g., a t Distribution or a Chi-Square Distribution, or can be approximated, e.g., using CLT
- the distribution of does not depend on the parameter
Such a test statistic is also called a pivot (quantity).
Then, we can first construct a confidence interval for the test statistic . Using the knowledge of its distribution (or quantiles), the confidence interval can be given by:
where is the -th quantile of the distribution of , and and are called the critical values.
Exact CI
Exact CIs are constructed using known quantile function and explicit expression of the test statistic .
Warm up
Construct the exact CI of estimating with 10 iid samples from . Use the look-up table of the Normal distribution quantiles.
For Bernoulli trials, let’s consider the sum of trials, , as the test statistic. follows a Binomial distribution, whose CDF satisfies:
where is the CDF of the Beta distribution with parameters and . Therefore, using exact beta distribution quantiles, a level exact CI for is
where is the -th quantile of the Beta distribution with parameters and .
Remark
Note that is not a random variable. However, treating it as a beta random variable (as in a Bayesian interpretation) gives us the same exact calculation as using the binomial distribution.
CLT CI
By CLT and LLN, we know that
where is the sample mean and is the sample variance. This gives the CLT CI:
where is the -th quantile of the standard normal distribution.
We can see that both exact CI and CLT CI have an average length of order . However, CLT CI is only asymptotically valid.
Hoeffding CI
Since Bernoulli trials are bounded, Hoeffding’s inequality gives
leading to a level CI:
We can see Hoeffding CI is super conservative: it has a much wider CI with a higher coverage than the nominal level.
Chebyshev CI
Construct another concentration inequality-based CI. For example, Chebyshev CI. And compare it with Hoeffding CI.
Wald CI
Another version of CLT CI is using the fact that
where is the standard error of the statistic . For sample mean, we know its standard error is
For Bernoulli distribution, instead of using a sample variance to estimate the variance, and hence estimate the standard error, as we did in constructing CLT CI, we notice that
Thus, we can estimate the standard error by plugging in the estimation of instead, using , giving the Wald plug-in CI:
Since Wald CI also uses CLT, it behaves similarly to CLT CI.
Wilson Score CI
Left as exercise
Comparison
We now compare the average length and coverage of the confidence intervals constructed above.
Takeaways
Summary of the methodology behind the above methods:
- Exact calculation is finite-sample valid, preferred when the test statistic’s distribution is known and easy to compute. Not practical for unknown distributions.
- CLT CI uses Central Limit Theorem and thus is asymptotically valid. It is preferred when the sample size is large. It does not leverage any structural information about the distribution.
- Hoeffding CI is one example of a concentration inequality-based CI. This class of CIs is finite-sample valid. Any concentration inequality can be used to construct a CI, and some are more suitable for specific distributions. Generally, concentration inequality-based CIs are more conservative.
- Wald CI uses the plug-in principle, which is asymptotically valid. It is preferred when the test statistic involves parameters that can be readily estimated; then the estimation is plugged into the CI formula.
- Wilson score CI constructs the CI by solving the inequality by CLT or other concentration inequalities. It leverages the structure of the test statistic but is preferred only when the inequality can be solved easily.
The width of the confidence interval, that is, its accuracy, depends on:
- The sample size n: the larger the sample size the narrow the width of the CI.
- The confidence level: the higher the confidence the wider the CI will be!
- The standard deviation of the population or SE: the larger the SE the wider the CI will be.
- The method used to construct the CI