liveBook · Manning

Analysis of variance

As explained in Statistics Slam Dunk

A one-way ANOVA tests whether the mean of a numeric response differs across levels of one categorical predictor.

Analysis of variance (ANOVA) tests whether a numeric outcome has different means across three or more groups. A one-way ANOVA uses one categorical predictor, making it useful for questions such as whether NBA teams in different scoring or points-allowed categories have different average win totals. section 14.5 section 14.5.2

ANOVA needs a quantitative target and a categorical predictor. For NBA wins, standardized points allowed and points scored can be converted into four factor levels: below -1, -1 to 0, 0 to 1, and above 1 standard deviation. Check the resulting category counts and missing values before modeling. section 14.5.1 section 20.4

nba_stats %>%
 mutate(o_pts_cat = case_when(z_o_pts < -1 ~ "A",
                              z_o_pts >= -1 & z_o_pts < 0 ~ "B",
                              z_o_pts >= 0 & z_o_pts <= 1 ~ "C",
                              z_o_pts > 1 ~ "D")) -> nba_stats
nba_stats$o_pts_cat <- as.factor(nba_stats$o_pts_cat)

Create a factor from standardized points allowed so teams can be compared as four categories rather than as one continuous measure. section 14.5.1

Plot the outcome by group before fitting the model. Boxplots show each category’s spread in standardized wins, while an overlaid mean makes group differences easier to inspect. This gives the statistical test a practical sports question: do scoring or defensive categories line up with winning? section 14.5.1

Fitting and checking two NBA ANOVAs

Fit `aov(z_wins ~ o_pts_cat, data = nba_stats)` for points allowed, then fit the same model with `pts_cat` for points scored. Both reported extremely small p-values, indicating differences in mean standardized wins across their four groups. Inspect Residuals vs. Fitted for equal group variances and Normal QQ for residual normality; compare the models with AIC when weighing the two predictors. section 14.5.2 section 14.5.2

A statistically significant ANOVA supports differences among group means, not the claim that one side of basketball is overwhelmingly more important. Here, points allowed and points scored showed similar effects on regular-season wins, so the broader defense-versus-offense claim remained qualified. section 14.8 section 20.4

How Statistics Slam Dunk covers it

How deep it goes
Walks through factor creation, boxplots, `aov()` fitting, p-value interpretation, diagnostic plots, and AIC comparison.
Examples
Uses 300 NBA team-season records, grouping standardized points allowed and scored into four categories against standardized wins.
What it assumes
Starts from required quantitative outcomes and categorical predictors, then demonstrates converting numeric standardized measures into factors.
What you can do after
Evaluate/understand whether mean wins differ across three or more categories using base R ANOVA output and diagnostics.
How it connects
Connects ANOVA with t-tests, simple linear regression, boxplots, residuals, AIC, correlation tests, and logistic regression.

Also explained in

Compare how 3 books explain analysis of variance →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Slam Dunk. The section links point to the parts of the book it draws on.