Day 1: Why Do We Care? — A First Look at the t-Test

10 points — graded

This is a preview, run before we've covered anything formally. You are not expected to know what most of these numbers mean yet — that's the point. The goal is to see a real research question answered start to finish, so that the next several weeks of descriptives, distributions, and sampling have an obvious reason to exist. We'll come back to this exact dataset, formally, in Chapter 15.

A note on AI tools: You may use AI assistants (ChatGPT, Claude, etc.) to help debug your R code — that's a realistic professional skill. You may not use AI to generate your interpretations. Every write-up sentence must reflect your own reading of the output. If you use AI for any part of this assignment, note where at the end.

Setup

One dataset, one line of code, nothing to download or upload:

df <- read.csv("https://jkoxford-a11y.github.io/awesomesaucestats/data/ttest_preview.csv") head(df)

This is a fictional classroom survey. Forty students, several things measured about each one. We're going to ask it three different questions.

The question

Twenty of the forty students studied the same vocabulary list for five minutes in silence. The other twenty studied it with café-style background chatter playing. Everyone was then tested on how many words they could recall.

Does studying with background chatter hurt recall?

Step 1: Look before you test

Before you scroll (self-check, not submitted): Which group do you predict will score higher — Silence or Chatter — and by roughly how much? Jot a guess before you plot anything.
boxplot(words_recalled ~ study_environment, data = df, main = "Words Recalled by Study Environment", ylab = "Words recalled")

Look at the two boxes. One group sits visibly higher than the other, with only a little overlap. Before we run anything, that plot is already suggesting an answer — we're about to check whether the data backs it up.

Step 2: Run the test

t.test(words_recalled ~ study_environment, data = df)
Welch Two Sample t-test data: words_recalled by study_environment t = -4.6571, df = 37.993, p-value = 3.853e-05 95 percent confidence interval: -5.953971 -2.346029 sample estimates: mean in group Chatter mean in group Silence 10.40 14.55
tapply(df$words_recalled, df$study_environment, sd)
Chatter Silence 2.798496 2.837252

Step 3: Pull out what matters

Six numbers to know how to find, even before you know exactly why each one looks the way it does:

WhatValueFor now, just know...
t−4.657A bigger distance from zero (either direction) means a bigger gap between the groups, relative to how noisy the data are.
df37.99Comes from your sample size. We'll unpack exactly how in a few weeks.
p3.85e-05 (0.0000385)The smaller this is, the less plausible it is that a gap this big happened by chance alone.
MeansChatter 10.40, Silence 14.55The group averages — what the plot was showing you visually.
SDsChatter 2.80, Silence 2.84How spread out each group's scores are around its mean.
Cohen's d1.47The size of the effect — how many standard deviations apart the two groups' averages are. p tells you "probably real"; d tells you "how big." We always report both, not just whichever one looks better.

p here is tiny — far smaller than the usual .05 cutoff you'll hear about soon. That's what "statistically significant" means: this result is a candidate for "probably not just chance."

So what's the answer? Forget the stats for a second — in plain language: students who studied with background chatter recalled fewer words, on average, than students who studied in silence, and the gap is too large to easily chalk up to chance — and it's a large effect, not just a statistically detectable one. That one sentence is the actual point. Everything above it is how we earned the right to say it.
Question 1 — 1 point (answer in your answer document): A t-test tells you the two groups differ — it doesn't tell you the chatter caused the difference. Suppose these forty students picked their own study condition instead of being assigned one. Name one reason the Silence group might have recalled more words for reasons that have nothing to do with the noise itself. (We'll come back to this formally in Chapter 15.)

Step 4: Your turn — two more questions

Same dataset, two different column pairs. For each one: predict first, then run the code and see if the data agrees.

Question 2: Handedness and sleep — fill in the blanks (2 points)

The same students also reported how many hours they slept the night before, and whether they're left- or right-handed.

Part of Question 2 — record in your answer document: Is there any reason handedness would predict sleep? Prediction first: do you think handedness will predict sleep here, or not — and why?

The code below has two blanks. Fill them in using the pattern from Step 1–2 before you run it:

boxplot(sleep_hours ~ ____, data = df, main = "Sleep Hours by Handedness", ylab = "Hours of sleep") tapply(df$sleep_hours, df$handedness, mean) tapply(df$sleep_hours, df$handedness, sd) ____(sleep_hours ~ handedness, data = df)
Rest of Question 2 — record in your answer document: Write your own one-sentence answer, plain language, no stats jargon: does handedness predict sleep here, or not?

Question 3: Seat location and test anxiety — write it yourself (2 points)

Twenty of the students sat in the front of the classroom all semester, twenty sat in the back. At the final, everyone rated their test anxiety from 1–10.

Does where you sit predict how anxious you feel at test time?

No starter code this time. Using the pattern from Questions 1 and 2, write R code to:

  1. Boxplot anxiety_score by seat_location
  2. Get the mean and SD of anxiety_score for each seat_location group
  3. Run the t-test comparing anxiety_score by seat_location
Question 3 — record in your answer document: Write your own one-sentence answer, plain language, no stats jargon: does seat location predict test anxiety here, or not?

Step 5: Compare all three

Fill in the row for Question 2 and Question 3 yourself, then look at the pattern:

QuestiontdfpVerdict
Recall (chatter vs. silence)−4.65737.990.0000385Clearly significant
Sleep (handedness)Fill in this row in your answer document
Anxiety (seat location)Fill in this row in your answer document
Part of Step 5 — 2 points (record the completed table and this answer): One of these three lands right around the .05 cutoff you'll hear so much about. When you find it: what would make you more confident it's real, one way or the other? (Hold onto that instinct — it's exactly what statistical power is about, later in the course.)

Notice too that p and Cohen's d don't have to tell the same story: a tiny effect can still hit significance with enough data, and a real effect can miss it with too little. That's exactly why we report effect size regardless of whether p is significant — "significant" and "big" are two different questions.

Step 6: Where do t and Cohen's d actually come from?

It's not magic — two formulas, using numbers you already have. The one new piece for t is SE, "standard error." Here's the idea: SE is a measure of how much you'd expect a group's mean to bounce around if you ran this study again and again with a new batch of 20 students each time. It's built from two things you already have: how spread out each group's scores are (SD) and how many people are in each group (n) — more spread means more bounce, more people means less. For the recall question:

t = (mean_Chatter − mean_Silence) / SE SE = sqrt( sd_Chatter² / n_Chatter + sd_Silence² / n_Silence ) = sqrt( 2.7985² / 20 + 2.8373² / 20 ) = 0.891 t = (10.40 − 14.55) / 0.891 = −4.657

Same number R gave us. The whole test is really just: how big is the gap between the groups, compared to how much the groups' means naturally jitter from sample to sample?

Cohen's d asks a related but different question — not "how big is the gap compared to sampling jitter," but "how big is the gap compared to how spread out scores normally are within a group":

d = (mean_Silence − mean_Chatter) / pooled SD = (14.55 − 10.40) / 2.818 = 1.47

Same means you already had, divided by a version of SD that blends both groups together. t and d are close cousins — both compare the gap between means to some measure of spread — but t divides by SE (which shrinks as sample size grows) while d divides by SD (which doesn't). That's why a study can gain a bigger t just by adding more people, without the effect itself getting any bigger — exactly the "significant vs. big" distinction from Step 5. Everything we cover for the next several weeks — populations vs. samples, why we look at spread, where df comes from — exists to make these formulas precise and trustworthy.

What we skipped (on purpose)

We didn't check any assumptions before running these tests. We didn't ask whether 20 students per group is "enough." We didn't talk about what a sample is standing in for, or why SD is the number we chose to measure spread. All of that is coming — this was just enough of a look at the destination to make the trip worth taking.

Look ahead: what does Chapter 15 already say?

You haven't read Chapter 15 yet, but it's already sitting in the book, and it covers two things this activity deliberately skipped: how to judge the size of a Cohen's d value, and how to read the confidence interval R printed but we didn't touch.

Question 4 — 3 points (answer in your answer document): Chapter 15 has a table of Cohen's d benchmarks. Using it: is d = 1.47 from the recall study small, medium, or large?

The 95% confidence interval for the mean difference was [−5.95, −2.35] (from your Step 2 output). In one sentence, what does that interval tell you that the single p-value doesn't?