3.3 How do we estimate a proportion?

What proportion of Indian wage earners work in urban areas? That is not an average. Do we need new machinery?

Many important quantities are proportions. The share of households below the poverty line, the share of children enrolled in school, the share of a workforce that is female, the unemployment rate. None of these is obviously an average, and it would be reasonable to expect a separate theory.

There is none, and the reason is a small trick.

Write down, for each person in the sample, a variable that equals 1 if they have the characteristic and 0 if they do not.

wages <- read.csv("data/wages-india-synthetic.csv")

is_urban <- as.numeric(wages$residence == "Urban")
head(is_urban, 20)
#>  [1] 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 0 0 1

The average of that column is the proportion of people with the characteristic. Adding up a column of ones and zeros counts the ones, and dividing by \(n\) turns the count into a share.

c(mean_of_indicator = mean(is_urban),
  proportion_urban  = sum(wages$residence == "Urban") / nrow(wages))
#> mean_of_indicator  proportion_urban 
#>            0.2684            0.2685

A proportion is a mean. The sample proportion

\[\hat{p} = \frac{x}{n}\]

where \(x\) is the number of observations with the characteristic, is exactly the sample mean of a variable coded 1 and 0.

Everything established about \(\bar{X}\) therefore applies to \(\hat{p}\) unchanged. It is unbiased, its variability falls with \(\sqrt{n}\), and the Central Limit Theorem makes it approximately normal in large samples.

This is worth pausing on, because it is the first time in the book that a result has been obtained for free. We did not prove anything new. We noticed that a question we had not met was a question we had already answered, wearing different clothes.

How much does a sample proportion vary?

One thing does simplify. For a general population we need \(\sigma\) from somewhere. For a 0/1 variable, \(\sigma\) is determined by \(p\) itself.

Let \(X_i\) equal 1 with probability \(p\) and 0 with probability \(1-p\). Then

\[E(X_i) = 1 \cdot p + 0 \cdot (1-p) = p\]

so the population mean of the indicator is the population proportion. For the variance, note that \(X_i^2 = X_i\), since \(0^2 = 0\) and \(1^2 = 1\). Hence \(E(X_i^2) = p\) and

\[\mathrm{Var}(X_i) = E(X_i^2) - \big[E(X_i)\big]^2 = p - p^2 = p(1-p)\]

Applying \(\mathrm{Var}(\bar{X}) = \sigma^2/n\) from the previous unit,

\[\mathrm{Var}(\hat{p}) = \frac{p(1-p)}{n} \qquad\qquad \mathrm{se}(\hat{p}) = \sqrt{\frac{p(1-p)}{n}}\]

In practice \(p\) is unknown — it is what we are estimating — so we substitute \(\hat{p}\):

\[\widehat{\mathrm{se}}(\hat{p}) = \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}\]

set.seed(8)
sample_urban <- sample(is_urban, 500)

p_hat <- mean(sample_urban)
se_p  <- sqrt(p_hat * (1 - p_hat) / 500)

round(c(p_hat = p_hat, se = se_p, true_p = mean(is_urban)), 4)
#>  p_hat     se true_p 
#> 0.2820 0.0201 0.2684

The quantity \(p(1-p)\) is largest at \(p = 0.5\) and falls away towards zero at either end.

That has a sensible meaning. A population evenly split is the hardest to pin down, because samples can land either way. A population where 99% share a characteristic is easy — almost every sample says 99%. Rare and near-universal things are estimated precisely; genuinely contested ones are not.

The consequence for survey design is that \(p = 0.5\) is the worst case, and a sample large enough for a 50-50 split is large enough for anything.