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).
# Data
sleep_hours <- c(6.5, 7, 6, 8, 6.8, 7.2, 6.1, 7.5, 6.9, 7)
# 1. Test whether the mean number of hours differs from 7
t_test_one_sample <- t.test(sleep_hours, mu = 7)
# Display results
t_test_one_sample
##
## One Sample t-test
##
## 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
Questions:
Compare exam scores between two teaching methods:
# Data
group_A <- c(75, 78, 74, 77, 73)
group_B <- c(82, 85, 88, 86, 84)
# 1. Two-sample t-test (assuming equal variance = FALSE by default)
t_test_two_sample <- t.test(group_A, group_B)
# Display results
t_test_two_sample
##
## 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
Questions: