TOOL
Confidence interval for a proportion
๐ ๏ธ Confidence interval for a proportion
๐ก Use Case
- Six lines I have pasted into every analysis since ๐ Lecture 6 - Confidence intervals: give it a count and a total, get back the proportion and a 95 percent interval.
- It is ๐ Confidence interval for a proportion in code and nothing cleverer.
- It exists so that I never again put a bare percentage on a slide. A percentage without its interval is an anecdote with a decimal point.
How I use it
What the six lines do, in order:
- Take
ksuccesses andntrials. p = k / n- Standard error: the square root of
p * (1 - p) / n. - Margin:
1.96times the standard error. - Lower and upper:
pminus and plus the margin. - Print all three as percentages, to one decimal.
Worked once, on my own numbers. Issue 31 went to 1,196 people and 52 percent opened it: about 622 opens.
| Step | Value |
|---|---|
| p | 0.52 |
| Standard error | 0.0144 |
| Margin (1.96 ร SE) | 0.028 |
| Interval | 49.2 to 54.8 percent |
What that does to me
An open rate that moves from 52 to 50 between two issues is inside this. I am not allowed a mood about it.
โ๏ธ Pros & Cons
Pros
- Six lines. I can read all of it and so can a reviewer.
- It prints the interval in the sentence form I am allowed to say, which is not the sentence I used to say (see ๐ค Confidence interval).
Cons
- It is the simple approximation. Near 0 or 100 percent, or with a few dozen cases, it is wrong, and it does not complain.
- It makes a number look more settled than the way the data was collected deserves.
๐ Alternatives
- A statistics library's own function, with better small-sample behaviour and one more thing to install.
- Asking Bao Nguyen, who will also ask how the sample was drawn.