In-Class Worksheet: t-Tests with Dataset A

Companion to Chapters 14–16 (One-Sample, Independent-Samples, and Paired t-Tests). Work with your group to decide which test applies, write the R code yourselves, and compose your own APA-style result for each scenario. Each student must type all code individually. You’ll receive the solutions guide (ttest-inclass-KEY.md) after class to check your approach before starting the homework (ttest-homework.md).

Dataset A: Snack & Productivity

Variable Description Type
snacks Daily snack calories consumed Numeric
study_group When the student typically studies Factor (Morning/Evening)
focus_pre Self-rated focus (1–10) before a snack Numeric
focus_post Self-rated focus (1–10) after a snack Numeric

Standard Setup

A <- read.csv("https://jkoxford-a11y.github.io/awesomesaucestats/data/dataset_A_snack_productivity.csv")
str(A)
head(A)

A Note on AI Tools

You may use AI to help debug your R code, but all interpretations must be your own.

What every scenario requires

For each scenario below: run the appropriate normality check, run the test, and write an APA-style result that includes t (with df), p, the 95% CI, and Cohen’s d. Report effect size regardless of whether the result is significant.

Scenario 1: One-Sample t-Test

Research question: Do students eat significantly different snack calories than the claimed 750/day?

Write your own code: normality check → t-test → APA write-up (t, df, p, 95% CI, Cohen’s d).

Scenario 2: Independent-Samples t-Test (Welch)

Research question: Do Morning vs. Evening study groups differ in snack calories?

Useful reference for group means/SDs:

tapply(A$snacks, A$study_group, mean)
tapply(A$snacks, A$study_group, sd)

Write your own code: normality check per group → t-test → APA write-up.

Scenario 3: Paired-Samples t-Test

Research question: Do focus ratings change from pre-snack to post-snack?

Reminder: for a paired test, check normality of the differences (post − pre), not each column separately.

Write your own code: normality check on differences → t-test → APA write-up.

Scenario 4: One-Tailed Paired t-Test

Research question: Is focus higher after snacks than before?

Write your own code: t-test with the correct directional alternative → APA write-up.

Reflection Question

Name one variable not in this dataset that could confound the relationship between snack consumption and focus. How might it change the interpretation of your results?