To conduct the z-test for the population proportion (p) using R, enter the commands:
p = prop.test(40,316,0.035,alternative="greater",conf.level=0.95, correct=FALSE); p
Z = sqrt(p$statistic); Z
Note: Using R—the command prop.test
returns X2 = 78.9, and it turns out that X2 = z2. Since the sample proportion p is larger than the hypothesized proportion p0, we know that Z is positive. Thus
The value of X2 is recovered with the command p$statistic
.