In: Statistics and Probability
DO NOT HANDWARITE PLEASE
DO NOT HANDWARITE PLEASE
Null Hypothesis H0: p1 = p2
Alternative Hypothesis H0: p1 p2
where p1 and p2 are the true proportions of people in compliance with law initially and after 1 year period.
For sample 1,
x1 = n1p1 = 1250 * 0.989 = 1236.25
n1(1-p1) = 1250 * (1 - 0.989) = 13.75
For sample 2,
x2 = n2p2 = 1100 * 0.969 = 1065.9
n1(1-p1) = 1100 * (1 - 0.969) = 34.1
Since, np > 10 and n(1-p) > 10, for both the samples , conditions for two proportion z test is satisfied.
Running two proportion z test in R, we get
n1 = 1250; n2 = 1100;
p1 = 0.989; p2 = 0.969
#Pooled sample proportion
p = (n1*p1+n2*p2)/(n1 + n2)
#standard error of sample proportion
se = sqrt(p*(1-p)*((1/n1)+(1/n2)))
#Test statistic,
z = (p1 - p2)/se
#p-value
p.value = 2 * pnorm(z, lower.tail = FALSE)
Test statistic,
> z
[1] 3.42537
P-value,
> p.value
[1] 0.0006139626
> se
[1] 0.005838785
Since p-value is less than 0.05 significance level, we reject null hypothesis H0 and conclude that there is significant evidence that p1 p2.
Margin of error = z * se = 1.96 * 0.005838785 = 0.01144402
95% confidence interval is,
Lower bound = (p1 - p2) - margin of error = (0.989 - 0.969) - 0.01144402 = 0.00855598
Upper bound = (p1 - p2) + margin of error = (0.989 - 0.969) + 0.01144402 = 0.03144402
We're 95% confident that the interval (0.00855598, 0.03144402) captured the true value of p1 - p2.