Instructions: Use RStudio to perform the following exercises. Show all code, output and interpret your results.
You collected the number of hours 10 students sleep on weeknights: c(6.5, 7, 6, 8, 6.8, 7.2, 6.1, 7.5, 6.9, 7).
Questions:
data: sleep_hours t = -0.52223, df = 9, p-value = 0.6141 alternative hypothesis: true mean is not equal to 7 95 percent confidence interval: 6.46683 7.33317 sample estimates: mean of x 6.9 2. Construct a 95% confidence interval.
sleep_hours <- c(6.5, 7, 6, 8, 6.8, 7.2, 6.1, 7.5, 6.9, 7)
Perform a t-test to get the 95% confidence interval
t_test <- t.test(sleep_hours, conf.level = 0.95)
Print the 95% confidence interval
t_test$conf.int [1] 6.46683 7.33317 attr(,“conf.level”) [1] 0.95
sleep_hours <- c(6.5, 7, 6, 8, 6.8, 7.2, 6.1, 7.5, 6.9, 7)
One-sided t-test: Is the mean less than 7?
t_test_less <- t.test(sleep_hours, mu = 7, alternative = “less”)
View results
print(t_test_less)
One Sample t-test
data: sleep_hours t = -0.52223, df = 9, p-value = 0.3071 alternative hypothesis: true mean is less than 7 95 percent confidence interval: -Inf 7.251014 sample estimates: mean of x 6.9 so yes
Compare exam scores between two teaching methods:
Questions:
group_A <- c(75, 78, 74, 77, 73) # Traditional > group_B <- c(82, 85, 88, 86, 84) # Online > > # Two-sample t-test (assuming equal variances by default) > t_test_result <- t.test(group_A, group_B) > > # Print result > print(t_test_result)
Welch Two Sample t-test
data: group_A and group_B t = -7.0391, df = 7.9549, p-value = 0.0001113 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -12.748074 -6.451926 sample estimates: mean of x mean of y 75.4 85.0
Is there a significant difference in average scores? yes since the p-value is significantly less than .05, there is strong evidence of a significant difference in average scores between the groups. The online group performed better with a mean of 85.0 as compared to the traditional group which had a mean score of 75.4.
Provide a 95% confidence interval for the difference in means.
Do the results suggest one method outperforms the other? The Online teaching method outperforms the Traditional method in terms of average exam scores. We know that since the p-score is smalled than .05, the difference is statistically signiificant, meaning its highly unlikely for the reults to be by random chance.