Aim: To test whether there is significant difference between two sample proportions
.
Problem:
Random samples of 400 men and 600 women asked whether they would like to have a fly over near
their residence. 200 men and 325 women were in favour of it. Test the equality of men and women
in the proposal.

R – Code:-
The null hypothesis H0: p1=p2
Alternate hypothesis H1: proportions are different
We begin with computing the test statistic.
> n1=400
# Sample1 size
> p1=200/n1
# Sample1 proportion
> n2=600
# Sample2 size
> p2=325/n2
# Sample2 proportion
> P=(n1*p1+n2*p2)/(n1+n2)
> Q=1-P
> z=abs((p1-p2)/sqrt(P*Q*(1/n1+1/n2)))
> z
# test statistic
[1] 1.292611
>alpha=0.05
>z.alpha=qnorm(1-alpha/2)
>z.alpha # critical value
[1] 1.959964