Topics / Chapter 6

From sample to population

To know in what range the true population value of a mean, proportion or variance you calculated from a sample lies, and how confidently you can say so.

How close does a sample figure get to the truth?

You weighed 16 Merino lambs and their mean birth weight came out at 3.2 kg. Is the true mean of every lamb in the flock also 3.2 kg? Almost certainly not. With 16 different lambs you might have got 3.0 or 3.5. Every number calculated from a sample is an estimate of the true population value, and it is a little off.

That is why an estimate is given in two ways:

  • Point estimate: a single number. “The mean birth weight is 3.2 kg.” The mean, variance or proportion calculated from a sample is a point estimate of the population parameter. It is not expected to equal the population value exactly.
  • Interval estimate (confidence limits): an interval drawn around the point estimate that contains the true value with a stated probability. “With 95% confidence, the mean birth weight is between 2.0 and 4.4 kg.”

An interval estimate says something a point estimate cannot: how sure you can be. A narrow interval means the estimate is precise; a wide one means the sample tells you little about the population.

What makes a good point estimate?

PropertyMeaningExample
UnbiasednessThe expected value of the estimate equals the population parameter; over repeated samples it is right on average.This is why we divide the variance by n−1n - 1 rather than nn.
ConsistencyAs the sample grows, the estimate approaches the population value.The mean of 1000 lambs is more reliable than that of 16.
EfficiencyThe estimate has a small variance, so it varies little from sample to sample.For normal data the arithmetic mean is more efficient than the median.
SufficiencyThe estimate uses all the information in the sample.The mean uses every value; the mode does not.

The logic of a confidence interval

The width of the interval depends on three things:

point estimate±table value⏟confidence level×standard error⏟spread and n\text{point estimate} \pm \underbrace{\text{table value}}_{\text{confidence level}} \times \underbrace{\text{standard error}}_{\text{spread and } n}
  • Confidence level: asking for 99% confidence makes the interval wider than at 95%. The price of being more sure is a less precise answer.
  • Spread of the data: the more scattered the values, the wider the interval.
  • Sample size: the standard error is divided by n\sqrt{n}, so the interval narrows as the sample grows. Halving the width takes four times as many observations.

Confidence limits are written as P(−zα/2<z<zα/2)=1−αP(-z_{\alpha/2} < z < z_{\alpha/2}) = 1 - \alpha. For 95% confidence α=0.05\alpha = 0.05; because the interval is two-sided, this error is split between the two tails and the table value is read for α/2=0.025\alpha/2 = 0.025.

Which distribution should I use?

Interval forSituationDistribution
One meanPopulation variance (σ2\sigma^2) knownZ
One meanσ2\sigma^2 unknown, n>30n > 30Z (ss in place of σ)
One meanσ2\sigma^2 unknown, n≤30n \le 30t (n−1n - 1 degrees of freedom)
Difference of two meansSmall samplest (n1+n2−2n_1 + n_2 - 2 degrees of freedom)
One proportion, difference of two proportionsCount dataZ
VarianceChi-square (n−1n - 1 degrees of freedom)

Why 30? In small samples ss can be quite a poor estimate of σ\sigma. The t distribution allows for this extra uncertainty: its tails are heavier than Z’s, its table value is larger and the interval wider. As the degrees of freedom increase, t approaches Z. At 30 degrees of freedom, for 95%, t = 2.042 against Z = 1.96, a difference of about 4% that keeps shrinking after that. “Use Z if n > 30” is therefore a practical shortcut. When calculating by computer, always using t is slightly more accurate.

Calculate with your own data

The calculator below is loaded with all six examples from the course notes. Pick one, then change the confidence level or the sample size and watch the interval narrow or widen.

Interval for what?
Examples from the course notes:

The standard deviation of the birth weight of Merino lambs is known to be 2.4 kg. 16 lambs chosen at random from the flock have a mean birth weight of 3.2 kg. What are the 95% confidence limits of the population mean?

Distribution to use: Z

2.0244.376point estimate 3.2

With 95% confidence, the population mean lies between 2.024 and 4.376.

Confidence limits

2.024 <μ<< \mu < 4.376

  1. The population standard deviation (σ) is known, so the Z distribution is used.

  2. Confidence level 1 − α = 0.95, so α = 0.05. The interval is two-sided, so α is split in half: α/2 = 0.025.

    P(−zα/2<z<zα/2)=1−α=0.95P(-z_{\alpha/2} < z < z_{\alpha/2}) = 1 - \alpha = 0.95
  3. The z value for α/2 = 0.025 from the Z table:

    z0.025=1.96z_{0.025} = 1.96
  4. Standard error of the mean:

    σxˉ=σn=2.416=0.6\sigma_{\bar{x}} = \dfrac{\sigma}{\sqrt{n}} = \dfrac{2.4}{\sqrt{16}} = 0.6
  5. μupper=xˉ+zα/2 σxˉ=3.2+1.96⋅0.6=4.376\mu_{\text{upper}} = \bar{x} + z_{\alpha/2}\,\sigma_{\bar{x}} = 3.2 + 1.96 \cdot 0.6 = 4.376
  6. μlower=xˉ−zα/2 σxˉ=3.2−1.96⋅0.6=2.024\mu_{\text{lower}} = \bar{x} - z_{\alpha/2}\,\sigma_{\bar{x}} = 3.2 - 1.96 \cdot 0.6 = 2.024

Formulas

One mean with Z (σ\sigma known or n>30n > 30):

μupper=xˉ+zα/2 σxˉ,μlower=xˉ−zα/2 σxˉ,σxˉ=σn\mu_{\text{upper}} = \bar{x} + z_{\alpha/2}\,\sigma_{\bar{x}}, \qquad \mu_{\text{lower}} = \bar{x} - z_{\alpha/2}\,\sigma_{\bar{x}}, \qquad \sigma_{\bar{x}} = \frac{\sigma}{\sqrt{n}}

One mean with t (σ\sigma unknown, n≤30n \le 30):

μupper, lower=xˉ±tα/2, n−1 Sxˉ,Sxˉ=S2n\mu_{\text{upper, lower}} = \bar{x} \pm t_{\alpha/2,\,n-1}\,S_{\bar{x}}, \qquad S_{\bar{x}} = \sqrt{\frac{S^2}{n}}

One proportion:

pupper, lower=p^±zα/2p^q^np_{\text{upper, lower}} = \hat{p} \pm z_{\alpha/2}\sqrt{\frac{\hat{p}\hat{q}}{n}}

Difference of two proportions:

(p1−p2)upper, lower=(p^1−p^2)±zα/2p^1q^1n1+p^2q^2n2(p_1 - p_2)_{\text{upper, lower}} = (\hat{p}_1 - \hat{p}_2) \pm z_{\alpha/2}\sqrt{\frac{\hat{p}_1\hat{q}_1}{n_1} + \frac{\hat{p}_2\hat{q}_2}{n_2}}

Difference of two means (pooled variance):

(μ1−μ2)upper, lower=(xˉ1−xˉ2)±Sxˉ1−xˉ2 tα/2, n1+n2−2,Sxˉ1−xˉ2=Sp2(1n1+1n2)(\mu_1 - \mu_2)_{\text{upper, lower}} = (\bar{x}_1 - \bar{x}_2) \pm S_{\bar{x}_1 - \bar{x}_2}\,t_{\alpha/2,\,n_1+n_2-2}, \qquad S_{\bar{x}_1 - \bar{x}_2} = \sqrt{S_p^2\left(\frac{1}{n_1} + \frac{1}{n_2}\right)} Sp2=(n1−1)S12+(n2−1)S22n1+n2−2S_p^2 = \frac{(n_1 - 1)S_1^2 + (n_2 - 1)S_2^2}{n_1 + n_2 - 2}

Variance with chi-square:

σupper2=S2(n−1)χA2,σlower2=S2(n−1)χB2\sigma^2_{\text{upper}} = \frac{S^2(n-1)}{\chi^2_A}, \qquad \sigma^2_{\text{lower}} = \frac{S^2(n-1)}{\chi^2_B}

Here χA2\chi^2_A and χB2\chi^2_B are read from the chi-square table. For 95% confidence and 29 degrees of freedom, χA2=χ0.975; 292=16.05\chi^2_A = \chi^2_{0.975;\,29} = 16.05 (the small value, which gives the upper limit) and χB2=χ0.025; 292=45.72\chi^2_B = \chi^2_{0.025;\,29} = 45.72 (the large value, which gives the lower limit). Because chi-square is not symmetric, neither is the interval around the sample variance.

Reading the result correctly

The interval is for the population mean, not for individual values. In the lamb example, the interval 2.024–4.376 kg does not mean “lambs’ birth weights vary within this range”; individual lambs are spread over a much wider range. The correct reading: “We can say with 95% confidence that the flock’s mean birth weight is between 2.024 and 4.376 kg.”

What does 95% mean? If you computed a hundred intervals from a hundred different samples with the same method, about 95 of them would contain the true population mean. The interval in your hands may or may not be one of those 95; the method is right 95% of the time in the long run.

If the interval for a difference contains zero: if the interval for the difference between two means or two proportions includes zero (negative lower limit, positive upper limit), there may be no real difference between the groups. This is equivalent to a non-significant two-sided test at the same level. A negative lower limit is not rounded to zero; it means “the first group could also be slightly lower than the second”. In the sunflower example the interval runs from about −8.1 to 20.1 cm: variety A could have heads 20 cm larger than B, or 8 cm smaller. These data cannot show a difference between the two varieties.

For proportions: a proportion cannot be negative, so a calculated lower limit below zero is read as 0. That usually means there were very few events, in which case the normal approximation is unreliable anyway.