# How to test a sample proportion against a known population value?

Say someone makes the argument "people who wear blue shoes steal more bananas." Then as proof they say, "the total population of blue shoe wearers is 30% of the population. Out of a random sample of 60 cases of banana theft, 40 of them were committed by people who exclusively wear blue shoes. That's 2x their rate of appearance in the population!"

What kind of test would be the right one to use to test their notion and its statistical significance? At first I figured z-test, but that would imply measuring a continuous variable, so I'm thinking something else should be more appropriate here.

The blue shoe wearers constitute 30% of the population, so if they were just as likely to steal as anybody else, approximately 0.3*60 = 18 of the 60 cases would be blue shoe wearers. So what you're interested in is to know the probability that 40/60 cases are positive when the probability of each case is 0.3. This is a problem involving the binomial distribution. Imagine that we do this experiment many times: we select 60 cases and see how many blue shoe wearers we get. On average, we should get around 18 cases. But how often will we get 40 cases or more? What is the probability that we get that many cases if the true probability for each case is 0.3? Using R:

pbinom(40,60,0.3)


This will give you the proportion of observations where the number of cases are lower than n=40 if the probability is 0.3.

So the proportion of observation that are 40 or higher is:

> 1 - pbinom(40,60,0.3)
[1] 1.050282e-09


So the probability to get 40 or more cases out of 60 if the probability is 0.3 is extremely small, p = 1.050282e-09. Now, to get a two-tailed p-value you should multiply this value by 2. This is understood as "if there is a true difference in probability between blue shoe wearers and the rest, what is the probability of getting such an extreme result or a more extreme result?". It is very common to report a two-tailed p-value in this way, because you then make no a priori assumptions about the direction of the effect (blue shoe wearers could either steal more or less than the others).

An alternative approach is to use the built-in binomial test function of R:

binom.test(40,60,0.3)

Exact binomial test

data:  40 and 60
number of successes = 40, number of trials = 60, p-value = 5.625e-09
alternative hypothesis: true probability of success is not equal to 0.3
95 percent confidence interval:
0.5331273 0.7831306
sample estimates:
probability of success
0.6666667


And now you also get the confidence intervals. As you can see, the lower limit of the confidence interval is much higher than 0.3 and the p-value is of course also very low.

Please note that all of this assumes that all who steal have an equal probability of getting caught. If blue shoe wearers do not steal more, but those who do are more likely to get caught (perhaps because the police are more likely to suspect blue shoe wearers of stealing), then a higher proportion of the cases will be blue shoe wearers even though they don't steal more often.

I hope this helps. Perhaps you want a more mathematically oriented answer. In that case, I'm sure somebody else can contribute.

• I edited the post a little. – JonB Oct 13 '15 at 7:26

How about the chi-square goodness-of-fit test. The null hypothesis is Ho: Blue Shoe Proportion = p = 0.3.

Then the chi-square statistic is $X2 = \sum{{(observed - expected)^2}\over{observed}}$ = (40 - 60*0.3)^2/(60*0.3) + (20 - 60*0.7)^2/(60*0.7) = 38.41. If you compare this to the null distribution, which is chi-square with df = 1, you get a p-value around 6e-10:

> chisq.test(c(40,20),p=c(0.3,0.7))

Chi-squared test for given probabilities

data:  c(40, 20)

X-squared = 38.4127, df = 1, p-value = 5.726e-10

• Why would you prefer that to the Binomial Distribution? – Eli Oct 13 '15 at 21:14
• Why would I prefer a chi-square test to a binomial? Technically the binomial is more "exact", but really, with this sample size it's not a big deal. And I get to ignore the fact that the binomial distribution isn't symmetric (which makes the rejection regions debatable). Anyway, from the problem statement, neither approach might be "perfect". They never stated that the same people weren't stealing bananas. (the same blue shoed guy could have stolen most of the bananas). Heh. – AlaskaRon Oct 14 '15 at 6:05