Educational Statistics and Research Methods (ESRM) Program*
University of Arkansas
Published
September 15, 2026
Example 2: Sleep Duration and Exam Scores
The example compares mean exam scores across three independent sleep-duration groups using a one-way analysis of variance (ANOVA).
Starting Data and Descriptive Statistics
The following code reproduces the starting dataset provided with Homework 1. The original column names are retained so that this answer matches the student starting code.
# Set seed for reproducibilityset.seed(42)# Generate data for three sleep groupsless_than_6_hours <-rnorm(30, mean =65, sd =10)six_to_eight_hours <-rnorm(50, mean =75, sd =8)more_than_8_hours <-rnorm(20, mean =78, sd =7)# Combine data into a single data framesleep_data <-data.frame(Sleep_Group =factor(c(rep("<6 hours", 30),rep("6-8 hours", 50),rep(">8 hours", 20) )),Exam_Score =c( less_than_6_hours, six_to_eight_hours, more_than_8_hours ))# View the first few rows of the datasethead(sleep_data)
The null hypothesis is that the population mean exam scores are equal across all three sleep-duration groups:
H_0:\mu_{<6}=\mu_{6\text{-}8}=\mu_{>8}.
The alternative hypothesis is that at least one population mean differs from another.
Q2. What is the value of the F-statistic for the student groups?
NoteAnswer
The ANOVA result is F(2, 97) = 14.15, with p = 4.06e-06.
Q3. Given alpha as 0.05, is the F-statistic significant?
NoteAnswer
Yes. The p-value is smaller than \alpha=.05, so the omnibus F-test is statistically significant.
Q4. Will you reject or retain the null hypothesis?
NoteAnswer
Reject the null hypothesis because the p-value is less than alpha. The result provides evidence that the population mean exam scores are not equal across all three sleep-duration groups. The omnibus ANOVA alone does not identify which specific group means differ; that question requires justified follow-up comparisons.
---title: "Homework 1 Answer"subtitle: "ESRM 64103: Experimental Design in Education"date: "September 15, 2026"draft: falseexecute: echo: true warning: false message: falseformat: html: code-tools: true code-line-numbers: false toc: true toc-depth: 2---# Example 2: Sleep Duration and Exam ScoresThe example compares mean exam scores across three independent sleep-duration groups using a one-way analysis of variance (ANOVA).## Starting Data and Descriptive StatisticsThe following code reproduces the starting dataset provided with Homework 1. The original column names are retained so that this answer matches the student starting code.```{r}#| label: generate-sleep-data# Set seed for reproducibilityset.seed(42)# Generate data for three sleep groupsless_than_6_hours <-rnorm(30, mean =65, sd =10)six_to_eight_hours <-rnorm(50, mean =75, sd =8)more_than_8_hours <-rnorm(20, mean =78, sd =7)# Combine data into a single data framesleep_data <-data.frame(Sleep_Group =factor(c(rep("<6 hours", 30),rep("6-8 hours", 50),rep(">8 hours", 20) )),Exam_Score =c( less_than_6_hours, six_to_eight_hours, more_than_8_hours ))# View the first few rows of the datasethead(sleep_data)``````{r}#| label: summarize-sleep-groupslibrary(dplyr)group_summary <- sleep_data |>group_by(Sleep_Group) |>summarise(Sample_Size =n(),Mean =mean(Exam_Score),Standard_Deviation =sd(Exam_Score),.groups ="drop" )group_summary```## One-Way ANOVA```{r}#| label: fit-homework-anovaanova_model <-aov(Exam_Score ~ Sleep_Group, data = sleep_data)anova_results <-summary(anova_model)anova_resultsanova_table <- anova_results[[1]]f_statistic <- anova_table[["F value"]][1]p_value <- anova_table[["Pr(>F)"]][1]numerator_df <- anova_table[["Df"]][1]denominator_df <- anova_table[["Df"]][2]```# Answers## Q1. What is the null hypothesis of Example 2?::: {.callout-note title="Answer"}The null hypothesis is that the population mean exam scores are equal across all three sleep-duration groups:$$H_0:\mu_{<6}=\mu_{6\text{-}8}=\mu_{>8}.$$The alternative hypothesis is that at least one population mean differs from another.:::## Q2. What is the value of the F-statistic for the student groups?::: {.callout-note title="Answer"}The ANOVA result is $F(`r numerator_df`, `r denominator_df`) = `r sprintf("%.2f", f_statistic)`$, with $p = `r format(p_value, scientific = TRUE, digits = 3)`$.:::## Q3. Given alpha as 0.05, is the F-statistic significant?::: {.callout-note title="Answer"}**Yes.** The p-value is smaller than $\alpha=.05$, so the omnibus F-test is statistically significant.:::## Q4. Will you reject or retain the null hypothesis?::: {.callout-note title="Answer"}**Reject the null hypothesis because the p-value is less than alpha.** The result provides evidence that the population mean exam scores are not equal across all three sleep-duration groups. The omnibus ANOVA alone does not identify which specific group means differ; that question requires justified follow-up comparisons.:::