# Hypothesis test for a population proportion

$H_0:$ the probability that a person has the characteristic A = $0.05$

$H_1:$ the probability that a person has the characteristic A $­\neq 0.05$

I take a sample of size $500$ and find that $40$ people ($0.08$) have the characteristic A. I want to test the null hypothesis with $\alpha = 0.01$.

First, I would have to find the sample's variance, which is $\dfrac{1}{500-1}(0.08-0.05)^2 = 0.0000018$, so the standard deviation is $0.00134$.

The discriminating function would be Student's T fonction. The observed T is $\dfrac{0.08-0.05}{0.00134}*\sqrt{500} = 499$. That means that the critical $\alpha$ value would be incredibly small. That seems a bit extreme, did I go wrong somewhere?

I don't see how the t distribution is appropriate here.

Test using normal approximation. Using the normal approximation to the binomial, we have the test statistic

$$Z = \frac{\hat \theta - \theta_0}{\sigma_{\hat \theta}},$$

where $\hat\theta = 40/500 = 0.08$ is the estimate of the true population proportion $\theta$ having the characteristic. Also $\theta_0 = 0.05$ is the hypothetical population proportion. And, according to $H_0$, $\sigma_{\hat \theta} = SD(\hat \theta) = \sqrt{\frac{\theta_0(1-\theta_0)}{n}}.$

Then, assuming $H_0$ to be true, $Z \stackrel{aprx}{\sim} Norm(0,1)$ and we reject $H_0$ at the 1% level if $|Z| > 2.576.$

Because $\theta_0 = 0.05,$ we get $SD(\hat \theta) = \sqrt{.05(.95)/500} = 0.009745.$ So $$Z = (.08 - .05)/.009745 = 3.08$$ and We reject $H_0$ because $|Z| = 3.08 > 2.576.$

The P-value in this situation is $P(|Z| > 3.08) = 0.0021.$

Reference: Except for notation, the exposition above follows very closely the explanation of the 'binomial test' in Ott & Longnecker, 7e, pp 488-489. Perhaps your textbook contains something similar.

Esact binomial test. Here is printout from Minitab's 'exact' test procedure for this test, which does not use the normal approximation. $H_0$ is rejected at the 1% level because the P-value is less than 0.01. Also, notice that the 99% CI for $\theta$ does not include 0.05.

 Test and CI for One Proportion

Test of p = 0.05 vs p ≠ 0.05

Exact
Sample   X    N  Sample p         99% CI         P-Value
1       40  500  0.080000  (0.051879, 0.116412)    0.005


Note: Requesting the normal approximation instead of the exact test in Minitab, one gets P-value 0.002, which agrees with our result from the normal approximation.

Plot of BINOM(500, .05). Perhaps more intuitively, here is a plot of your hypothetical binomial distribution with $n = 500$ and $\theta = .05$ over the span of $x$-values where it has substantial probability. Notice that your observed value $x = 40$ is very far out into the right tail of this distribution. The exact P-value from Minitab is essentially double the (very small) probability in this distribution to the right of $x = 40.$

Addendum (5 hrs later): Some users seem to be offended by any computer code at all on this site (perhaps preferring duck quill pens and oxblood/charcoal ink on papyrus). I try to keep blood pressures low by omitting detailed code for my graphs. But @Brandon has requested code for the plot above, so here it is.

 x = 10:45;  pdf=dbinom(x, 500, .05)
plot(x, pdf, lwd=2, col="blue", type="h", ylab="PDF",
main="PDF of BINOM(500, .05)")
abline(h=0, col="green2")
abline(v=40, col="red", lty="dashed", lwd=2)

• I can't find the formula for the standard deviation. Instead, I find that the variance is np(1-p). Why are we dividing by n? – Bob Tremblay Dec 4 '16 at 18:19
• Because that's how to find SE for normal distribution – Brandon Dec 4 '16 at 18:52
• @BruceET would prop.test in R not be useful here compared to the binom.test. I ran some examples(specifically x = 44, n = 63 and p =.8) and prop.test yielded a p-value < .05 and the binom.test yielded a p-value > .05. Is this because of the exactness in binom.test? Is it because prop.test uses the Wilson and not the Wald, and is an approximation, not exact? I know in practice you could report both methods but I'm curious you're thoughts ? Sorry for all the questions – Brandon Dec 4 '16 at 19:02
• $Var(\hat\theta) = Var(X/n) = \frac{1}{n^2} Var(X) = \frac{n\theta(1-\theta)}{n^2} = \theta(1-\theta)/n.$ – BruceET Dec 4 '16 at 22:45
• @Brandon: Code still lurking in my R Console window, so pasted it into Answ. – BruceET Dec 4 '16 at 23:45