options(scipen=999)
options(digits=9)
cat("\014") # clear screen
rm(list=ls(all=TRUE))


d0=0
alpha=0.05
n1=200
x1=120
n2=500
x2=240
pcap=(x1+x2)/(n1+n2);pcap
pcap1=x1/n1;pcap1
pcap2=x2/n2;pcap2
p_difference=pcap1-pcap2;p_difference
standard_error=sqrt((pcap*(1-pcap))/n1+(pcap*(1-pcap))/n2)
standard_error
z_compute=(pcap1-pcap2-d0)/standard_error;z_compute
one_tailed_sig=1-pnorm(abs(z_compute),0,1);one_tailed_sig
two_tailed_sig=2*one_tailed_sig;two_tailed_sig
z_critical=qnorm(1-alpha,0,1);z_critical



