Professional Documents
Culture Documents
> IQ.data <- c(100, 101, 104, 109, 125, 116, 105, 108, 110)
> z.test <- function(x,mu,popvar){
one.tail.p <- NULL
z.score <- round((mean(x)-mu)/(popvar/sqrt(length(x))),3)
one.tail.p <- round(pnorm(abs(z.score),lower.tail=
FALSE),3)
cat(" z =",z.score,"\n",
"one-tailed probability =", one.tail.p,"\n",
"two-tailed probability =", 2*one.tail.p )}
> z.test(IQ.data,100,15)
z = 1.733
one-tailed probability = 0.042
two-tailed probability = 0.084
In the above R output, you have the value of the 𝑧-test statistic and the 𝑝-value
for both one-tailed and two-tailed tests. The 𝑝-value is equal to 0.042 which is
less than 𝛼 = 0.05. Hence, we reject 𝐻0 .
A telephone company representative estimates that 40% of its customers have call-
waiting service. To test this hypothesis, she selected a sample of 100 customers
and found out that 37% of them had call waiting. At 𝛼 = 0.01, is there enough
evidence to reject the claim?
Let 𝑝 be the proportion of the telephone company’s customers who have call-
waiting service. We want to test
𝐻0 : 𝑝 = 0.40 vs 𝐻1 : 𝑝 ≠ 0.40
The p=NULL argument is where you specify 𝑝0 . Moreover, change the default
correct=FALSE to correct=TRUE to use a continuity correction in the
calculation instead.
Note that the function reports the squared value of the 𝑧-test statistic that you
learned. In the above R output, you have the sample proportion, the 99%
confidence interval estimate, the squared value of the 𝑧-test statistic, and the 𝑝-
value. The 𝑝-value is equal to 0.5403 which is greater than 𝛼 = 0.01. Hence,
we do not reject 𝐻0 .
Solve the following problems manually first. Put your manual calculations in an MS
Word document and interpret your answers. Use the following format. Save the MS
Word file as “(YOUR SURNAME)_LabEx7.docx”.
𝐻0 : ________________________________
𝐻1 : ________________________________
𝛼 = _______________________________
Decision Rule: ___________________________________________
Test Statistic: ____________________________________________
Critical Value: ____________________________________________
Decision: ________________________________________________
Conclusion: ______________________________________________
Then, use the appropriate R codes to conduct the hypothesis testing. Make sure
that your results in R coincide with your manual computations. Include screenshots
of your codes and outputs in the R Console in the MS Word document. Save the
R file as “(YOUR SURNAME_LabEx7.R)”.