Confidence Intervals and Hypothesis Testing


Confidence Intervals and Hypothesis Testing

Corey
Hi, and welcome to the second session of our basic statistics course. Today we're focusing on three connected ideas: confidence intervals, hypothesis testing, and p-values.

Michael
And underneath those topics is a bigger question: how do we use information from a sample to learn about a whole population? We'll also look at sampling variation, the difference between precision and accuracy, and why standard error matters.

Corey
Let's begin with a fictional weight-loss study. Imagine recruiting 100 women between 20 and 35 years old, measuring their weight before and after a weight-loss program, and calculating the average change.

Michael
Before the program, the average weight was 70 kilograms. Afterwards, it was 66.3 kilograms, so the average weight loss was 3.7 kilograms. That sounds promising, but an average difference by itself does not tell us whether the program really caused weight loss or whether the difference could have happened through chance.

Corey
Exactly. To judge how convincing the result is, we need information such as a confidence interval or a p-value. In this example, the 95% confidence interval for the average weight loss runs from 3.4 to 4.0 kilograms.

Michael
So we interpret that as being 95% confident that the true average weight loss in the population is somewhere between 3.4 and 4 kilograms. Even the lower end, 3.4 kilograms, represents a substantial average reduction.

Corey
The p-value is also very small, which means the result is highly statistically significant. We'll unpack exactly what that means, but the basic message is that the observed result would be very unlikely if there were actually no effect.

Michael
Before we go further, let's connect this to a real published study. A 2013 Lancet randomized controlled trial examined electronic cigarettes for smoking cessation.

Corey
The researchers compared three groups: people using nicotine-containing e-cigarettes, people using e-cigarettes without nicotine as a placebo group, and people using nicotine patches. In the paper, the results are presented as an estimate, followed by a confidence interval and a p-value.

Michael
For example, the nicotine e-cigarette group had a reported time to relapse of 35 days, with its confidence interval. The researchers then compared that group with the nicotine-patch group and separately with the placebo e-cigarette group.

Corey
An important detail is that each p-value refers to a comparison between groups. The confidence interval describes the estimate for the group or difference being reported, while the p-value helps assess how compatible the observed difference is with a null hypothesis of no difference.

Michael
So how do we move from a sample to a population? Usually, we're interested in a population, but measuring every person in that population is rarely possible.

Corey
Instead, we recruit a sample that is intended to represent the population and measure outcomes in that sample. We might calculate a mean, a median, a proportion, or a percentage. But the real goal is to use that sample measurement to say something about the population.

Michael
That process is called statistical inference. Standard errors, confidence intervals, and p-values help us judge how much uncertainty there is around what we observed and whether the result might plausibly be due to chance.

Corey
There are several common uses. We might estimate a population characteristic, such as the percentage of smokers in the UK. We might compare measurements before and after an intervention, as in the weight-loss example, or compare two treatment groups, such as e-cigarettes versus placebo e-cigarettes.

Michael
We can also compare one active treatment with another. The e-cigarette study compared e-cigarettes with nicotine patches, and a different example would be comparing paracetamol with ibuprofen using pain scores. Even when the outcome is a score without physical units, we can still report an estimate and a confidence interval.

Corey
For the weight-loss example, the population of interest is women in the UK aged 20 to 35. The sample consists of women from that population who took part in the study. The outcome is mean weight loss in kilograms, and the aim is to estimate the true average weight loss in the population.

Michael
But because we only study a subset of people, we should not expect the sample result to equal the exact population truth. If we repeated the study in the same general way, we'd recruit different people and would probably get a slightly different average weight loss.

Corey
Those differences from sample to sample are called sampling variation, or sampling error. The results would hopefully be similar, but they would not be identical. That is why we need ways to describe how dependable our sample estimate is.

Michael
Two words are especially important here: precision and accuracy. They are related, but they do not mean the same thing.

Corey
Precision describes how close repeated measurements are to one another. Accuracy describes how close the measurements are to the truth. Imagine a set of arrows aimed at a bullseye: the bullseye represents the true value.

Michael
Arrows can be close together but all miss the bullseye. That is high precision but low accuracy. They can also be spread out but, on average, surround the bullseye, which is lower precision but better accuracy. The ideal situation is to be both precise and accurate.

Corey
Across repeated studies, accuracy concerns whether the average of the study estimates is close to the true population value. Precision concerns how spread out those study estimates are. A narrow spread means the studies tend to produce similar answers.

Michael
The key limitation is that we can calculate precision, but we generally cannot calculate accuracy directly, because the true population value is usually unknown. Standard error is the measure we use for precision.

Corey
A larger standard error means lower precision, while a smaller standard error means higher precision. Precision can improve with a larger sample size, and it also improves when the standard deviation of the measured variable is lower.

Michael
The standard error of a mean is calculated by dividing the standard deviation by the square root of the sample size. So, in the weight-loss study, if the standard deviation is 1.5 kilograms and there are 100 participants, the standard error is 1.5 divided by the square root of 100, which equals 0.15 kilograms.

Corey
Standard error is not always shown directly in published papers, but it is essential because it is used to calculate confidence intervals. It tells us how much sample estimates are expected to vary from study to study.

Michael
To understand confidence intervals, imagine having unlimited resources and repeating the same study 1,000 times. Each time, you recruit a new sample of 20 women and calculate the average weight loss.

Corey
You would get a distribution of study means rather than individual participant measurements. Most studies might find a weight loss around 2.5 kilograms, but some could find more than 5 kilograms, no weight loss, or even a negative weight loss, meaning that average weight increased.

Michael
Those study means form a distribution, and the normal-distribution rule applies. About 95% of values in a normal distribution fall within roughly two standard deviations of the mean. For a distribution of sample means, the relevant spread is measured in standard errors.

Corey
That is where the 95% confidence interval comes from: it is based on the sample mean plus or minus roughly two standard errors. In the usual calculation, the multiplier is 1.96.

Michael
In real life, we cannot repeat our study 1,000 times, so we do not know exactly where our one study falls within that distribution of possible study results. We use our sample's standard deviation and sample size to estimate the standard error, then construct a confidence interval around the observed mean.

Corey
The calculation is: lower limit equals the sample mean minus 1.96 times the standard error, and upper limit equals the sample mean plus 1.96 times the standard error.

Michael
For the weight-loss example, the estimate is 3.7 kilograms and the standard error is 0.15 kilograms. So the interval is calculated as 3.7 minus 1.96 times 0.15, and 3.7 plus 1.96 times 0.15. That gives an interval from approximately 3.4 to 4.0 kilograms.

Corey
The sample estimate will always sit exactly in the middle of its confidence interval. A narrow confidence interval indicates a precise estimate, while a wide confidence interval indicates a less precise estimate.

Michael
There is also a useful repeated-study interpretation. If we carried out the same procedure many times, about 95% of the confidence intervals would contain the true population value, while about 5% would not.

Corey
We cannot know whether our particular study is one of the 95% whose interval contains the truth or one of the roughly 5% whose interval misses it. We choose the 95% confidence level, accepting that a small proportion of intervals will not contain the true value.

Michael
Systematic reviews and meta-analyses provide a practical way to combine evidence from many studies. A forest plot shows each study's estimate and confidence interval, along with a line representing no effect. Combining the studies can produce an estimate that is closer to the truth than any individual study.

Corey
Now let's turn to hypothesis testing. Every statistical test begins with a null hypothesis. The null hypothesis states that there is no effect or no difference.

Michael
For the weight-loss study, the null hypothesis could be that average weight before and after the intervention is the same, or that the intervention has no effect on weight.

Corey
Once we define that hypothesis, we ask whether the observed difference could be explained by sampling variation. In other words, if the program truly had no effect, how likely would it be to observe a result like the one we found?

Michael
That probability is summarized by the p-value. A p-value of 0.001 means there is a probability of 0.001 of observing an estimate like this, assuming the null hypothesis is true. In the lecture's wording, that is a one-in-1,000 probability.

Corey
A p-value of 0.1 would mean a probability of 0.1, or one in ten, of observing a result like this if the null hypothesis were true. That is much less unusual than a p-value of 0.001.

Michael
So a p-value is not the probability that the null hypothesis is true. It is the probability of observing the result, or something like it, under the assumption that the null hypothesis is true.

Corey
To picture this, assume the weight-loss program is ineffective. Under that null hypothesis, the true difference is zero. If we repeated the study many times, most sample results would be close to zero, although some would show a small loss and others might even show an increase in weight because of sampling variation.

Michael
A statistical test asks how far our observed estimate is from the no-effect value in standard-error units. In the weight-loss example, the no-effect value is zero, the observed effect is 3.7 kilograms, and the standard error is 0.15 kilograms.

Corey
That places the observed estimate more than 30 standard errors away from zero. A result that far from the null value would be extremely unusual if there were truly no effect, which is why the p-value is less than 0.001.

Michael
The smaller the p-value, the stronger the evidence against the null hypothesis. In this example, the very small p-value provides strong evidence that the observed weight loss is not simply due to sampling variation.

Corey
Putting the results together, we could write: We are 95% confident that the true effect of the intervention is a weight loss between 3.4 and 4 kilograms, and the probability that the observed difference arose by chance, meaning sampling variation, is less than one in a thousand.

Michael
Let's return to the smoking-cessation paper. The nicotine e-cigarette group had an estimated median time to relapse of 35 days, with a confidence interval from 15 to 56 days.

Corey
For the nicotine-patch group, the estimated true number of days to relapse was presented as being between 8 and 18 days according to its confidence interval. For the placebo e-cigarette group, the interval was between 5 and 34 days.

Michael
The broader lesson is that when reading a paper, look for three things: the estimate, the confidence interval around it, and the p-value for the relevant comparison. The estimate gives the study's result, the confidence interval shows its precision and plausible range, and the p-value describes how unusual the result would be under a no-effect hypothesis.

Corey
So we've covered the full chain: samples are used to infer population values; repeated samples differ because of sampling variation; precision and accuracy are different; standard error measures precision; confidence intervals quantify uncertainty around estimates; and p-values assess evidence against a null hypothesis.

Michael
And in the weight-loss example, the 3.7-kilogram estimate, the 3.4-to-4.0-kilogram confidence interval, and the very small p-value all point toward a statistically significant average reduction in weight.

Ask anything
We've read this whole study set, so questions about it get the best answers.