You are on page 1of 4

Here it is, all together:

> 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 .

ONE-SAMPLE TEST OF PROPORTIONS

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

In R, the prop.test() function will perform a test for a population proportion


for a large sample (at least 10 successes and failures). Let x be the number of
successes and n be the total number of trials.

Laboratory Manual in STAT 123 (Probability and Statistics) 52


The general syntax is as follows:

> prop.test(x, n, alternative=c("two.sided", "less",

"greater"), p=NULL, correct=FALSE)

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.

> prop.test(37, 100, alternative=c("two.sided"), p=0.40,


correct=FALSE, conf.level=.99)

1-sample proportions test without continuity correction

data: 37 out of 100, null probability 0.4


X-squared = 0.375, df = 1, p-value = 0.5403
alternative hypothesis: true p is not equal to 0.4
99 percent confidence interval:
0.2573863 0.4987911
sample estimates:
p
0.37

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 .

Laboratory Manual in STAT 123 (Probability and Statistics) 53


Exercise:

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)”.

1. Average weekly earnings for those working in IT industry is $623. A group


of employees working for a large IT firm felt that they earned more. The
mean weekly earnings for a random sample of 21 employees showed an
average weekly earning of $650 with a standard deviation of $72.
a) At 𝛼 = 0.01, can it be concluded that the employees are correct?
b) Construct a 99% confidence interval for the average weekly earnings
for those working in IT industry.

Laboratory Manual in STAT 123 (Probability and Statistics) 54


2. As a quality assurance tester, you have to accept or reject a large shipment
of items. For quality control purposes, you collected a sample of 200 items
and found 24 defective items in it.
a) The manufacturer claims that at most one in 10 items in the shipment
is defective. At the 4% level of significance, do we have sufficient
evidence to disprove this claim?
b) Construct a 96% confidence interval for the proportion of defective
items in the whole shipment.

3. In order to ensure efficient usage of a server, it is necessary to estimate the


mean number of concurrent users. According to records, the average number
of concurrent users at 100 randomly selected times is 37.70, with a standard
deviation 𝜎 = 9.20.
a) At the 1% significance level, do these data provide significant evidence
that the mean number of concurrent users is greater than 35?
b) Construct a 99% confidence interval for the expectation of the number
of concurrent users. Interpret the interval estimate.

4. A researcher claims that 47% of adults in the Philippines have Facebook


accounts. To test this hypothesis, 1487 adults in the Philippines were surveyed
and 640 of them said that they have Facebook accounts.
a) Do these data provide sufficient evidence to reject the claim at 5% level
of significance?
b) Construct a 95% confidence interval for the proportion of adults in the
Philippines who have Facebook accounts. Interpret the interval estimate.

Laboratory Manual in STAT 123 (Probability and Statistics) 55

You might also like