z-test for the Population Proportion

p = prop.test(x=40,n=316,p=0.035,alternative="greater",conf.level=0.95, correct=FALSE);p
## 
##  1-sample proportions test without continuity correction
## 
## data:  40 out of 316, null probability 0.035
## X-squared = 78.472, df = 1, p-value < 2.2e-16
## alternative hypothesis: true p is greater than 0.035
## 95 percent confidence interval:
##  0.09895287 1.00000000
## sample estimates:
##         p 
## 0.1265823
z = sqrt(p$statistic);z
## X-squared 
##  8.858441

Issues in Hypothesis Testing

p = prop.test(x=78,n=400,p=0.20,alternative="less",conf.level=0.95, correct=FALSE);p
## 
##  1-sample proportions test without continuity correction
## 
## data:  78 out of 400, null probability 0.2
## X-squared = 0.0625, df = 1, p-value = 0.4013
## alternative hypothesis: true p is less than 0.2
## 95 percent confidence interval:
##  0.0000000 0.2295887
## sample estimates:
##     p 
## 0.195
z = -sqrt(p$statistic);z
## X-squared 
##     -0.25
p = prop.test(x=3900,n=20000,p=0.20,alternative="less",conf.level=0.95, correct=FALSE);p
## 
##  1-sample proportions test without continuity correction
## 
## data:  3900 out of 20000, null probability 0.2
## X-squared = 3.125, df = 1, p-value = 0.03855
## alternative hypothesis: true p is less than 0.2
## 95 percent confidence interval:
##  0.0000000 0.1996493
## sample estimates:
##     p 
## 0.195
z = -sqrt(p$statistic);z
## X-squared 
## -1.767767