Inference Lab

S26 · Chapter 13

Today’s Agenda

  • Choosing the test
  • Reporting the result
  • A model for each test
  • Effect sizes and null results
  • The White Paper
  • Your own questions

Today’s Job

  • Tuesday the test ran on the example data; today you fill the Inferencing Data worksheet
    • Each test correctly chosen, correctly read, honestly reported
    • The same settings block, changed, runs on your own data for the paper

Open the Worksheet

  • In VS Code’s Explorer, open 13-inferencing-data-mc451.qmd, the copy you saved in your workspace’s top folder
  • Work in the worksheet, not in the console (the R terminal, where typed lines are not saved)
  • Check your work against the Inferencing Data risks guide

Pick Your Test First

For each pair in the worksheet’s Part 0, fill in three lines:

  • My outcome variable is ______, and it is numeric or categorical
  • I compare it across, or predict it from, ______: two groups, three or more groups, or a number
  • Therefore the test is ______

Pick Your Test First (cont.)

  • A number and two groups: t-test
  • A number and three or more groups: ANOVA
  • Two categories: chi-square
  • A number and a number, or a number and two groups coded 0 and 1: linear regression

Check Your Choice

  • The R Companion checks the third line against the first two; it does not write it
  • Click the AURA Lab R Companion icon on VS Code’s left edge; under Test, click Check my test choice

Test 1, the Chi-Square

  • Two categories call for chi-square: does the split between gaming and non-gaming change across the three viewer bands?
  • This is Part 2 of the worksheet, with cat_a and cat_b from the settings block
  • The R Companion writes it: under Test, Chi-square test with Cramer’s V
counts <- xtabs(~ cat_a + cat_b, data = analysis)
counts
sum(counts)
chi <- chisq.test(counts)
chi
cramers_v(counts, adjust = FALSE)

Test 1, the Output

        cat_b
cat_a    gaming non-gaming
  small   25309       2457
  medium   4000       1000
  large    2000          0
[1] 34766
  • counts is the grid: each viewer band split into gaming and non-gaming messages
  • 34766 is N, the number of messages the test used

Test 1, the Output (cont.)

    Pearson's Chi-squared test

data:  counts
X-squared = 822.66, df = 2, p-value < 2.2e-16

Cramer's V |       95% CI
-------------------------
0.15       | [0.14, 1.00]

- One-sided CIs: upper bound fixed at [1.00].
  • X-squared is the chi-square statistic; df is (rows - 1) times (columns - 1), here 2
  • p-value < 2.2e-16 is smaller than R will print, so p < .001
  • Cramér’s V is the effect size for two categories, from 0 (no link) to 1; 0.15 is small

Test 2, the t-test

  • The R Companion writes this same code for the names in your settings block: in its panel, under Test, Welch t-test with Cohen’s d
analysis %>%
  filter(!is.na(outcome), !is.na(group2)) %>%
  group_by(group2) %>%
  summarize(n = n(),
            mean = mean(outcome),
            sd = sd(outcome))

t.test(outcome ~ group2, data = analysis)
cohens_d(outcome ~ group2, data = analysis)

Test 2, the t-test (cont.)

  • outcome and group2 are the names the settings block gives your two columns; in the example they were message_length and is_gaming
  • The first pipe prints each group’s n, mean, and sd
  • t.test() prints both means, t, the Welch df, p, and a confidence interval; cohens_d() (from effectsize) adds the effect size
  • The R Companion’s Settings block (name the test variables) writes group2 = factor(channel_type)
    • Change that one line to your hand-coded variable, reaction_only, or the t-test runs on channel type
  • Older worksheets called run_t_test(); v2v keeps it as a deprecated shortcut, and this is the code you write

Exercise: Significant but Small?

  • Gaming and non-gaming message length: p below .001, Cohen’s d = -0.13
  • Cohen’s benchmarks: 0.2 small, 0.5 medium, 0.8 large
  • A headline reads “Gamers write much shorter messages”: does this result support the word “much”?

Report It in One Line

This is the compact form journals expect, written with the example study’s numbers:

Gaming channels produced shorter chat messages on average than non-gaming channels (28.49 vs. 33.70 characters; n = 31,305 and 3,457), Welch’s t(3768.7) = -4.94, p < .001, Cohen’s d = -0.13.

  • Every element earns its place: both means, each group’s n, the test with its degrees of freedom, the p-value, and the effect size
  • Never report p alone
  • The R Companion’s APA numbers to check your sentence prints these numbers from your own run; check your sentence against it

Then Say It Again in Plain English

  • A string of statistics is not an interpretation
    • Write a second sentence a reader with no statistics can understand
  • For the example study: the two kinds of channel do differ in message length, and the difference is so small that the two are better thought of as alike
  • That second sentence is the call: it reports the result without inflating it
  • The R Companion’s APA numbers to check your sentence prints the numbers to check; both sentences are yours to write

If you cannot write that sentence, you do not yet understand your result.

Effect Size, Every Time

  • Statistical significance asks: can the effect be distinguished from zero?
  • Practical significance asks: is the effect large enough to matter?
  • These are different questions, and large samples pull them apart
  • A finding is honestly reported only when both answers are on the page

“Significant” without a d is a claim you have not supported.

When p Is Above .05

set.seed(2026)
small <- analysis %>%
  filter(!is.na(cat_b)) %>%
  slice_sample(n = 30)

t.test(outcome ~ cat_b, data = small)
cohens_d(outcome ~ cat_b, data = small)
  • Tuesday’s comparison again, on 30 messages drawn at random instead of 34,762
  • set.seed() makes the random draw the same every time it runs

When p Is Above .05 (cont.)

    Welch Two Sample t-test

data:  outcome by cat_b
t = 1.7881, df = 27.665, p-value = 0.08473
alternative hypothesis: true difference in means between group gaming and group non-gaming is not equal to 0
95 percent confidence interval:
 -4.856628 71.279705
sample estimates:
    mean in group gaming mean in group non-gaming
                48.46154                 15.25000
  • p = .085 is above .05: this test cannot rule out chance
  • The interval runs from about -5 to 71 characters, so it holds zero

When p Is Above .05 (cont.)

Cohen's d |        95% CI
-------------------------
0.39      | [-0.68, 1.44]

- Estimated using pooled SD.
  • Not significant is not evidence of no difference: d’s interval runs from -0.68 to 1.44
  • Report it in full anyway: both means, t, df, p, and d, then say that 30 messages were too few to tell
  • Test 2 runs on your thirty hand-coded messages, so it may land here too; that is a result, not a failure

If You Have More Than Two Groups

fit_anova <- aov(outcome ~ group3, data = analysis)
summary(fit_anova)
eta_squared(fit_anova)
  • This is Part 4 of the worksheet: group3 is the three viewer bands
  • aov() fits the ANOVA, summary() prints the F table, and eta_squared() adds the effect size
  • How to read F and eta-squared: Tuesday’s ANOVA slides
  • The R Companion’s One-way ANOVA with eta squared writes the same lines

If You Want a Model

fit_lm <- lm(outcome ~ predictor, data = analysis)
summary(fit_lm)
  • In the worksheet, predictor is the hour of the day, a number
  • In the Coefficients table, the Estimate on the predictor row is the slope: characters gained for each hour later in the day
  • The worksheet lists the slope and p you should see; report the Multiple R-squared line beside them
  • A t-test is a regression with one two-level grouping variable, and an ANOVA is a regression with one many-level grouping variable: same framework, different shape

Reporting a Chi-Square

Chapter 13, two categorical variables

Whether a message carried an at-mention was associated with whether its channel was gaming, χ²(1, N = 34,762) = 31.15, p < .001, Cramér’s V = .03.

  • χ²(1, N = 34,762) = 31.15: the statistic, its df, and the number of messages
  • Cramér’s V = .03: the effect size, with no zero before the point because V never passes 1
  • Common mistake: leaving out N, or calling the link strong because p is tiny

Reporting an ANOVA

Chapter 13, more than two groups

Mean message length differed across the four game categories (N = 13,433), F(3, 13429) = 92.26, p < .001, η² = .02. League of Legends chat ran shortest (M = 22.63 characters) and Just Chatting chat longest (M = 39.03).

  • F(3, 13429): categories minus 1, then messages minus categories
  • η² = .02: game category accounts for about two percent of the variation
  • Common mistake: naming which pairs differ from F alone; that takes a follow-up test

Reporting a Regression

Chapter 13, from difference to model

Gaming status, coded 1 for gaming and 0 for non-gaming channels, was associated with message length, b = -5.21, SE = 0.74, t(34760) = -7.06, p < .001, R² = .001.

  • Coded 1 and 0: gaming status is a dummy variable, so the slope is the gap between the groups
  • b = -5.21: the slope, in characters; R² = .001: the share of variation it explains
  • Common mistake: writing that gaming causes shorter messages; a slope describes an association
  • In the worksheet the predictor is a number, so the slope is characters per hour; the sentence keeps this shape

Common Errors and What They Mean

  • must have exactly 2 levels: your grouping column has one group, or three or more
  • not enough 'x' observations: your filter left almost no rows
  • A p of exactly 1: the two groups are identical, usually because of a bad join
  • NA for the mean: add na.rm = TRUE, then ask why values are missing
  • An impossibly large t: you compared a variable to itself

Any Other Error

  • Select the error R printed in the terminal, then press Ctrl+C (Cmd+C on a Mac) to copy it
  • Click the AURA Lab R Companion icon on VS Code’s left edge; under Help, click Explain an R error: the copied error is filled in for you

The White Paper, 250 Points

  • Assigned today, due Friday, December 18, 11:59 PM
  • The full study written up as one reproducible document
    • An abstract, then Introduction, Methods, Results, and Discussion, then a Reflection
  • It is not a term paper. It is a document an invested reader could act on
  • It is rendered from Quarto, so every number in it comes from your code
  • You submit one ZIP file holding the paper PDF and your AI-use log, plus the live URL of your GitHub Pages site pasted into the submission

What Goes In It

  • Abstract: 150 to 250 words carrying the question, the method, the finding, and the implication
  • Introduction: your question, and why it is worth asking, with the literature cited
  • Methods: the sampling plan, the codebook, the reliability report, and the wrangling steps
  • Results: figures, a table, the test, and at least three qualitative themes, stated without interpretation
  • Discussion: what the result means, what it does not mean, and your limits, including the single-coder design
  • Reflection: one honest paragraph on what proved harder than expected and what you would change

You Have Written Most of It Already

  • Your prospectus is the spine of the Introduction
  • Your codebook and your sampling plan are most of the Methods
  • The figures from the Describing lab and the test from today’s lab are the Results
  • Today’s two sentences are the heart of the Discussion

The work left is assembly and honesty, not starting over.

Now Your Own Study

  • The Inferencing Data worksheet runs its tests on the Twitch example; your White Paper runs on your own questions
  • Your questions are in your Prospectus, under Research questions or hypotheses
  • For each one, settle three things before the break:
    • Which variables it names
    • Whether each variable is discrete or continuous
    • Which test the pair calls for

Discrete or Continuous

Discrete (categorical): each value is a category you count, not a number you average. Example: gaming or non-gaming, a viewer band, a code from your codebook.

Continuous (numeric): each value is a measured number where an average makes sense. Example: message length in characters, the hour of the day.

  • Ask: would “the average ______” make sense? Yes means continuous; no means discrete
  • A code stored as a number is still discrete: 1 for apology and 2 for denial are labels

A Number or a Category

Dummy variable: a category recoded as 0 and 1 so a regression can use it. Example: non-gaming is 0 and gaming is 1.

  • The outcome is always a number, such as message length
  • A number as predictor: the slope is the change per one-unit step, such as characters per hour
  • A two-group category as predictor: R makes gaming status a dummy for you
    • Its slope, -5.21, is the gap in means the t-test found
  • So two groups can take either the t-test or a regression with a dummy
  • The R Companion’s regression takes two numbers, so type it: lm(message_length ~ is_gaming, data = analysis)

One Hypothesis, Worked Through

H1: Gaming channels produce shorter chat messages than non-gaming channels.

Variable Discrete or continuous Role
Message length Continuous Outcome
Gaming status Discrete, two groups Other variable
  • Test: Welch t-test, with Cohen’s d

The Variables Choose the Test

Outcome Other variable Test
Discrete Discrete Chi-square, Cramér’s V
Continuous Two groups Welch t-test, Cohen’s d
Continuous Three or more groups One-way ANOVA, eta squared
Continuous Continuous, or a dummy coded 0 and 1 Linear regression, R²
One variable alone None Counts and percents, no test
One variable, predicted (“mostly X”) None Chi-square goodness of fit
  • Two numbers can also take a correlation, r: Chapter 13

Your Turn: Your Questions

Checkpoint

You should now have, in your worksheet:

  • A chosen test, with a written reason for choosing it
  • Output showing the means, the test statistic, p, and the effect size
  • The one-line statistical report, in the format of the model for your test, and its plain-English sentence
  • The White Paper assignment open, and its rubric read
  • The RQ and Hypothesis worksheet, one table per question, each with its variables and its test

Inferencing Data, Due December 4

Before Next Time

  • Due Friday, November 20, 11:59 PM: Describing Data in R, 75 points
  • Read Chapter 14, “The one-click report,” before Tuesday
  • Tuesday is The Publisher: bring your figures and your test output
  • Start thinking about your title

Questions, Comments, or Concerns?