You are on page 1of 3

INTERNATIONAL UNIVERSITY STATISTICS FOR SOCIAL SCIENCES (2020-21, S2)

ENGLISH DEPARTMENT Dr. Vu Hoa Ngan

HOMEWORK PROBLEM 2: COMPARING TWO VARIANCES & TWO MEANS

Instructions: Use the following samples of R codes to answer the questions below.

Scenario: Sixty freshmen were randomly selected from a list of about 2,500 freshman. The 60
students were divided into two groups: control group (face-to-face learning) and experimental
group (online learning). All 60 students took two grammar tests: one pretest at the beginning of
the semester, and one posttest under identical testing conditions. The datasets of their raw
scores: GrammarTest.csv; GrammarTest_control.csv; GrammarTest_experimental.csv

Part 1: Comparing two variances


R functions: var.test()
#Importing dataset into R
data <- read.csv("GrammarTest.csv", stringsAsFactors=FALSE)
# F-test to compare two variances between the two groups in terms of Pretest scores
var.test(Pretest ~ Group, data, alternative = "two.sided", conf.level = 0.95)

1. Compute F test to compare two variances between the two groups in terms of Posttest
scores; & provide R codes & R output.
2. What can be concluded from the results?
3. Compute a 95% confidence interval for F statistic. Interpret the results.
Answer:
1. R codes:
read.csv("GrammarTest.csv", stringsAsFactors=FALSE)
var.test(Posttest ~ Group, data, alternative = "two.sided", conf.level = 0.95)
R output:
F test to compare two variances

data: Posttest by Group


F = 1.0956, num df = 29, denom df = 29, p-value = 0.8074
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.5214812 2.3019137
sample estimates:
ratio of variances
1.09563

2. As in the R result, p-value = 0.8074 > α = 0.05


There is not sufficient evidence to support the rejection of the claim that the control group
(face-to-face learning) and experimental group (online learning) have equal variance in terms of
posttest scores

3. As in the R result, 95% confidence interval for F statistic is: 95% CI [0.521; 2.302].
The result indicates that the researchers are 95% confident that the true ratio of two variances
between control group (face-to-face learning) and experimental group (online learning) in
terms of posttest scores would range from 0.521 to 2.302 in the population of 2,500 students

1
Part 2: Comparing two independent samples means
R functions: t.test()

#Compute independent t-test: comparing pretest scores of two groups, assuming equal
variances
t.test(Pretest ~ Group, data = data, var.equal = TRUE, alternative = "two.sided", conf.level =
0.95)
#Compute independent t-test: comparing pretest scores of two groups, assuming unequal
variances
t.test(Pretest ~ Group, data = data, var.equal = FALSE, alternative = "two.sided", conf.level =
0.95)

1. Compute independent sample t-test to compare posttest scores between the 2 groups; &
provide R codes and R output.
(Note: you need to refer to results of Part 1 to use appropriate R codes for assuming
equal or unequal variances.)
2. What is the conclusion from the results?
3. Report and interpret the CI.
Answer:
1. R code:
t.test(Posttest ~ Group, data = data, var.equal = TRUE, alternative =
"two.sided", conf.level = 0.95)

R output:
Two Sample t-test

data: Posttest by Group


t = 0.043661, df = 58, p-value = 0.9653
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-7.474425 7.807758
sample estimates:
mean in group control mean in group experimental
64.93333 64.76667
2. As in the R result, p-value = 0.9653 > α = 0.05
There is not sufficient evidence to support the rejection of the claim that the control group
(face-to-face learning) and experimental group (online learning) have the same mean posttest
scores
3. As in the R result, the confidence interval of 95% CI [-7.474; 7.808]
The result indicates that the researchers are 95% confident that the limits of -7.474 and 7.808
include difference between the means of the two groups. In this range has the number 0,
therefore, there is not significant difference between the mean posttest score of the control
group (face-to-face learning) and experimental group (online learning)

2
Part 3: Comparing two paired samples means

• Step 1:
Create a dataset for Control group (GrammarTest_control.cvs)
• Step 2:
# Import Pretest Posttest scores of the Control group
Control <- read.csv("GrammarTest_control.csv", stringsAsFactors=FALSE)
#Compute Paired t test for the Control group
t.test(Scores~Test, data = Control, paired = TRUE)

1. Compute paired samples t-test for the experimental group. Provide R codes & R output.
2. What is the conclusion from the results?
3. Report and interpret the CI.

Answer:
1. R code:
Experimental <-read.csv("GrammarTest_experimental.csv",stringsAsFactors=FALSE)
t.test(Scores ~ Test, data = Experimental, paired = TRUE)

R output:
Paired t-test

data: Scores by Test


t = 0.82066, df = 29, p-value = 0.4185
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-4.227815 9.894481
sample estimates:
mean of the differences
2.833333
2. As in the R result, p-value = 0.4185 > α = 0.05
There is not sufficient evidence to support the rejection of the claim that for the pretest and
posttest scores of the experimental group (online learning), the differences have a mean equal
to 0. Or there is not sufficient evidence to claim that students in experimental group (online
learning) could have equal pretest and posttest scores.
3. As in the R result, the confidence interval of 95% CI [-4.228; 9.894]
The result indicates that the researchers are 95% confident that the limits of -4.228 and 9.894
include the true value of the mean of the pretest and posttest score differences. In this range it
has number 0, therefore, there is not significant difference between the mean pretest score and
the mean posttest score of the experimental group (online learning).

You might also like