# How can I test the difference between a population proportion and sample proportion?

A report says that 82% of British Columbians over the age of $25$ are high school graduates. A survey of randomly selected residents of a certain city included $1290$ who were over the age of $25$, and $1012$ of them were high school graduates. Is the city's result of $1012$ unusually high, low, or neither?

How should I approach this question? Any help and hints would be appreciated.

• Do you have any more information about the report? How many people were interviewed to come up with that 82% number? Did some fo them come from the city of interest? Feb 16 '13 at 5:49
• No, above are all the given information. Feb 16 '13 at 20:48

A report says that 82% of British Columbians over the age of 25 are high school graduates.

So population proportion is 0.82

A survey of randomly selected residents of a certain city included 1290 who were over the age of 25, and 1012 of them were high school graduates.

1012/1290 is the sample proportion, and 1290 is the sample size.

But I guess you knew these!

Unless you've done confidence intervals or standard errors of proportions, I expect you're just expected to simply compare the proportions as numbers.

Is the city's result of 1012 unusually high, low, or neither?

You could do a two sided one sample proportions test to answer such a question.

How should I approach this question? Any help and hints would be appreciated.

If you need to do a proportions test you'll have been shown how to do it (likely with a Z test).

You can search our site for proportions tests, or a web-search like:

e.g. this has a worked example

• I looked through the examples, but I haven't learned anything about hypothesis testing or two-sided test yet, so I don't think that's how I should approach the problem Feb 16 '13 at 20:48
• Then unless you've done confidence intervals or standard errors of proportions, I expect you're just expected to simply compare the proportions as numbers. Feb 16 '13 at 23:58
• yes, I got the right answer by simply comparing the proportions as numbers. thank you for the help :) Feb 19 '13 at 7:15

[Since @user59036 has resolved the question satisfactorily as per his last comment, I guess it's fair game for me to now attempt to resolve the problem using the standard errors and confidence intervals of proportions as suggested by Glen for future reference (or discussion / criticism).]

First off let me get the algebraic nomenclature out of the way - I find this extremely slippery and often implied:

(i) $\pi_0$ is a reference value assumed to be true. It is not necessarily the population proportion, but rather a fixed fraction or proportion to which we compare the sample to. For instance, the problem reads something along the lines: "Is our sample consistent with a population proportion of $\small \pi_0 = 0.7$?"

(ii) $\pi$ (or $p$) stands for the actual population proportion, but it's too bad that we usually don't know it and have to use instead the...

(iii) $\hat \pi$ (or $\hat p$), which stands for the sample proportion. To make things more "friendly" sometimes $p$ denotes the sample proportion...

(iv) $n$ is the number of trials in the binomial experiment (or the number of sampled subjects in a poll).

(v) $\small Y$ number of "successes" ("success" interpreted sometimes like the word "positive" in Medicine - you don't necessarily want it for yourself).

We are done! Well almost...

In our case we have $\small \pi = 0.82$ and $\small \hat \pi = 1012/1290 = 0.78$. And $\small n = 1290$.

The MLE of $\pi$ is the sample proportion, $\hat \pi = \small successes/trials$, and the expectation for the number of $\small successes$ is $n\pi$. The sample proportion is an unbiased estimator of the population: $\small E(\hat \pi)=\pi$ (and $\small E(Y)=n\pi$) and the standard error behaves very similarly to that of sampling distributions of sample means: $\small SE\,(\hat \pi) = \sqrt{\frac{\pi(1-\pi)}{n}}$, remembering that $var(\hat \pi)= \pi(1-\pi)$ (and $var(Y)=n\pi(1-\pi)$).

The test here as Glen indicates is a two-sided one-sample proportion test: $H_0: \pi = \pi_0$ versus $H_A: \pi \neq \pi_0$. Typically, a normal approximation with mean $\pi$ and $var = \pi(1-\pi)/n$ under the following conditions: $n\hat\pi>5$ and $n(1-\hat\pi)>5$. In our case this is clearly met ($\small 1290 * 0.78 = 1006$).

The $z$ test statistic is $\large z=\Large\frac{\hat\pi-\pi_0}{\sqrt{\frac{\pi_0\,(1-\pi_0)}{n}}}$. In our case, $z =\large \frac{0.78 - 0.82}{\sqrt{\frac{0.82(1-0.82)}{1290}}}=\large \frac{-0.04}{\sqrt{\frac{0.15}{1290}}}= \small-3.32$, which is clearly significant since c(-1,1) * qnorm(1 - 0.05/2) =  -1.96 1.96, and pnorm(-3.32) =0.00045. This latter expression corresponding to the [R] code for the two-tailed cut-off quantile values fixing the alpha significance level at 5%: $z_{(1 - \alpha/2)}$ where $\small \alpha = 0.05$.

As for the Wald confidence intervals, the calculation is:

$\large \hat \pi \pm z_{(1-\alpha/2)}\,\sqrt{\frac{\hat\pi(1-\hat\pi)}{n}}$. Coded in [R]:

0.78 + c(-1,1) * qnorm(1 - 0.05/2) * sqrt((0.78 * (1 - 0.78)) / 1290) = 0.7573946 to 0.8026054, which does not include $\small \pi_0 = 0.82$.

Since we know the population proportion $\pi$ in this case as being $0.82$ we can use it to construct the confidence interval as: $\large \pi \pm z_{(1-\alpha/2)}\,\sqrt{\frac{\pi(1-\pi)}{n}}$, or: 0.82 + c(-1,1) * qnorm(1 - 0.05/2) * sqrt((0.82 * (1 - 0.82)) / 1290) = 0.7990349 to 0.8409651. This excludes the sample value $0.78$.

Reference:

Categorical Data Analysis, Second Edition by Alan Agresti (p. 14)

• You assumed $\alpha=0.05$; you should probably state that's your significance level explicitly before using it, probably somewhere in your list of information you give. The test will also be significant at any other typical significance level, though, so the particular significance level chosen isn't critical (pun not intended). Oct 4 '15 at 11:38
• @Glen_b Thank you! Since I made an effort to spell out every symbol used (and I still doubt I did a good job at defining $\pi_o$ as opposed to $\pi$) it makes also a lot of sense to be explicit with the level alpha. I will correct this oversight. Oct 4 '15 at 12:25
• Because the population proportion of $0.82$ is stipulated in this question, it is more powerful to use it instead of the estimate based on the sample. In effect, the question (which, as a comment by @rpierce hints, is badly formulated and unrealistic in assuming the $0.82$ is exactly known) is asking "If you draw a random sample of size $1290$ from a Binomial distribution with mean $0.82$, then how 'unusual' would a value of $1012$ be?" No estimation or testing procedure is needed to answer such a question--in fact, such statistical apparatus is extraneous and irrelevant.
– whuber
Oct 4 '15 at 13:46
• @whuber Thank you for chiming in on the topic. Regarding the first line of your comment, and to make sure I got the idea, are you suggesting changing to $0.82$ the value entered in the Wald interval? As for your second comment, Am I getting it right if I interpret is as implying that the whole thing could be summarized in: pbinom(1012, size=1290, 0.82) = 0.0006549? Oct 4 '15 at 16:14
• Ah--there is the heart of the matter. Because the question refers to unusually high and low, we ought to give some thought to exactly how the degree of "unusualness" ought to be evaluated. Some people, inspired by two-sided testing, would doubtless recommend something like 1-abs(1-2*pbinom(1012, 1290, .82)). Yet others might argue on behalf of f <- dbinom(0:1290, 1290, .82); sum(f[f <= dbinom(1012, 1290, .82)]), which is slightly less.
– whuber
Oct 4 '15 at 18:07