Professional Documents
Culture Documents
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
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
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
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