On the Difference in Proportions
Can we say that the sentiment for increasing the speed limit is stronger among rural than among urban residents?
We can use a hypothesis testing framework to address this question.
Last week, we learned how Fisher’s Exact test could be used to verify the difference in proportions. The test-statistic for the two-sample hypothesis test follows a hypergeometric distribution when is true.
We also learned that, in more generalized cases where the number of successes is not known apriori, we could assume that the number of successes is fixed at , and, for a fixed value of , we reject for the alternate hypothesis if there are more successes in random variable compared to .
In short, the p-value can be derived under the assumption that the number of successes in the first sample has a hypergeometric distribution when is true and conditional on a total number of t successes that can come from any of the two random variables and .
Let’s apply this principle to the two samples that Joe and Mumble collected.
Let be the random variable that denotes Joe’s rural sample. He surveyed a total of people and favored an increase in the speed limit. So the proportion based on the number of successes is 0.7.
Let be the random variable that denotes Mumble’s urban sample. He surveyed a total of people. out of the 18 favored an increase in the speed limit. So the proportion based on the number of successes is 0.2778.
Let the total number of successes in both the samples be .
Let’s also establish the null and alternate hypotheses.
The alternate hypothesis says that the sentiment for increasing the speed limit is stronger among rural () than among urban residents ().
Larger values of and smaller values of support the alternate hypothesis that when t is fixed.
For a fixed value of t, we reject , if there are more number of successes in compared to .
Conditional on a total number of t successes from any of the two random variables, the number of successes in the first sample has a hypergeometric distribution when is true.
In the rural sample that Joe surveyed, seven favored an increase in the speed limit. So we can compute the p-value as the probability of obtaining more than seven successes in a rural sample of 10 when the total successes t from either urban or rural samples are twelve.
A total of 12 successes exist, out of which the number of ways of choosing 7 is .
A total of 28 – 12 = 16 non-successes exist, out of which the number of ways of choosing 10 – 7 = 3 non-successes is .
A total sample of 10 + 18 = 28 exists, out of which the number of ways of choosing ten samples is .
When we put them together, we can derive the probability for the hypergeometric distribution when is true.
Applying the same logic for k = 8, 9, and 10, we can derive their respective probabilities.
The p-value can be computed as the sum of these probabilities.
Visually, the null distribution will look like this.
The p-value is the probability of obtaining the computed test statistic under the null hypothesis.
The smaller the p-value, the less likely the observed statistic under the null hypothesis – and stronger evidence of rejecting the null.
Suppose we select a rate of error of 5%.
Since the p-value (0.0386) is smaller than our selected rate of error (0.05), we reject the null hypothesis for the alternate view that the sentiment for increasing the speed limit is stronger among rural () than among urban residents ().
Let me remind you that this decision is based on the assumption that the null hypothesis is correct. Under this assumption, since we selected , we will reject the true null hypothesis 5% of the time. At the same time, we will fail to reject the null hypothesis 95% of the time. In other words, 95% of the time, our decision to not reject the null hypothesis will be correct.
What if Joe and Mumble surveyed many more people?
You must be wondering that Joe and Mumble surveyed just a few people, which is not enough to derive any decent conclusion for a question like this. Perhaps they just called up their friends!
Let’s do a thought experiment. How would the null distribution look like if Joe and Mumble had double the sample size and the successes also increase in the same proportion? Would the p-value change?
Say Joe had surveyed 20 people, and 14 had favored an increase in the speed limit. .
Say Mumble had surveyed 36 people, and 10 had favored an increase in the speed limit. .
p-value will then be when there are 24 total successes.
The null distribution will look like this.
Notice that the null distribution is much more symmetric and looks like a bell curve (normal distribution) with an increase in the sample size. The p-value is 0.0026. More substantial evidence for rejecting the null hypothesis.
Is there a limiting distribution for the difference in proportion? If there is one, can we use it as the null distribution for the hypothesis test on the difference in proportion when the sample sizes are large.
While we embark on this derivation, let’s ask Joe and Mumble to survey many more people. When they are back, we will use new data to test the hypothesis.
But first, what is the limiting distribution for the difference in proportion?
We have two samples and of sizes and .
We might observe and successes in each of these samples. Hence, the proportions can be estimated using and .
See, we are using as the estimates of the true proportions .
Take . If the probability of success (proportion) is , in a sample of , we could observe successes with a probabilty that is governed by a binomial distribution. In other words,
Same logic applies to .
A binomial distribution tends to a normal distribution for large sample sizes; it can be estimated very accurately using the normal density function. We learned this in Lesson 48.
If you are curious as to how a binomial distribution function can approximated to a normal density function , look at this link.
But what is the limiting distribution for and ?
is the sum of independent Bernoulli random variables (yes or no responses from the people). For a large enough sample size , the distribution function of , which is a binomial distribution, can be well-approximated by the normal distribution. Since is a linear function of , the random variable can also be assumed to be normally distributed.
When both and are normally distributed, and when they are independent of each other, their sum or difference will also be normally distributed. We can derive it using the convolution of and .
Let
since both
If , we can standardize it to a standard normal variable as
We should now derive the expected value and the variance of Y.
Since they are independent, the co-variability term which carries the negative sign is zero.
We know that and . Recall Lesson 76.
When we put them together,
and finally since ,
A few more steps and we are done. Joe and Mumble must be waiting for us.
The null hypothesis is . Or, .
We need the distribution under the null hypothesis — the null distribution.
Under the null hypothesis, let’s assume that is , a common value for the two population proportions.
Then, the expected value of Y, and the variance
This shared value for the two population proportions can be estimated by pooling the samples together into one sample of size where there are and total successes.
Look at this estimate carefully. Can you see that the pooled estimate is a weighted average of the two proportions ( and )?
.
.
.
Okay, tell me what and are? Aren’t they and for the given two samples?
So
or,
At any rate,
To summarize, when the null hypothesis is
for large sample sizes, the test-statistic
If the alternate hypothesis is , we reject the null hypothesis when the p-value is less than the rate of rejection . We can also say that when , we reject the null hypothesis.
If the alternate hypothesis is , we reject the null hypothesis when the p-value is less than the rate of rejection . Or when , we reject the null hypothesis.
If the alternate hypothesis is , we reject the null hypothesis when the p-value or is less than the rate of rejection . Or when or , we reject the null hypothesis.
Okay, we are done. Let’s see what Joe and Mumble have.
The rural sample has and .
The urban sample has and .
Let’s first compute the estimates for the respective proportions — and .
Then, let’s compute the pooled estimate for the population proportions.
Next, let’s compute the test-statistics under the large-sample assumption. 190 and 310 are pretty large samples.
Since our alternate hypothesis is , we compute the p-value as,
Since the p-value (~0) is smaller than our selected rate of error (0.05), we reject the null hypothesis for the alternate view that the sentiment for increasing the speed limit is stronger among rural () than among urban residents ().
Remember that the test-statistic is computed for the null hypothesis that . What if the null hypothesis is not that the difference in proportions is zero but is equal to some value?
If you find this useful, please like, share and subscribe.
You can also follow me on Twitter @realDevineni for updates on new lessons.