Instructions: Use RStudio to perform the following exercises. Show all code, output and interpret your results.

One-Sample T-Test (10 pts)

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:

  1. Test whether the mean number of hours differs from 7.
  2. Construct a 95% confidence interval.
  3. Does the data suggest students get less than 7 hours of sleep? There is no evidence students sleep less than 7 hours on average.

Two-Sample T-Test (10 pts)

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:

  1. Use a two-sample t-test to compare the groups.
  2. Is there a significant difference in average scores? There is a significant difference in average scores.
  3. Provide a 95% confidence interval for the difference in means.
  4. Do the results suggest one method outperforms the other? Yes, the results suggest that group B outperforms group A.