Lab 11: Tests and Models
A t-test, an ANOVA, a linear model, and a column summary.
Work in a Quarto document. Do 11.1
and 11.2 first. Prefer mtcars,
palmerpenguins, or iris so the lab runs
without extra files. Sleuth3 is optional.
library(tidyverse)
library(palmerpenguins)
1. Two-sample t-test
- Boxplot of a numeric variable by a two-level group.
t.test()with the formulay ~ group. Save the object.
Use mpg by am in mtcars, or
Adelie vs Gentoo bill length in penguins after
filter() and droplevels(). State H0 in words.
Report the p-value as evidence against that H0.
2. ANOVA
aov() of a numeric variable by a factor with
three or more levels. Save the fit and
summary() it.
bill_length_mm ~ species in penguins,
mpg ~ factor(cyl) in mtcars, or
Sepal.Length ~ Species in iris are all fine.
State H0 in words.
3. Regression
lm() with two predictors. Interpret one
coefficient in a sentence (holding the other predictor fixed). Glance at
the residual-versus-fitted plot (plot(fit, which = 1) or
broom::augment()).
mpg ~ wt + hp in mtcars is the intended
default.
4. Column summaries
across()on every numeric column: mean and sd,.names = "{.col}_{.fn}",na.rmvia a formula~ mean(.x, na.rm = TRUE).- If
skimris installed,skimr::skim()on the same table.