liveBook · Manning

Plot() function

As explained in Statistics Slam Dunk

The plot() function is a base R generic function that produces graphical representations of R objects and fitted models.

plot() is a base R generic that turns fitted models and other R objects into graphics. For model analysis, it produces diagnostic plots that reveal whether assumptions such as linearity, normality, and equal variance are reasonable. section 5.7.5 section 14.5.2

Common model-analysis uses include:

  • Inspect a linear regression with plot(fit1), optionally arranging four diagnostics with par(mfrow = c(2, 2)). section 5.7.5
  • Read Residuals vs. Fitted and Normal QQ plots to evaluate residual behavior, normality, and possible assumption violations. section 5.7.5 section 14.5.2
  • Visualize a regression tree with plot(fit3), then add branch labels using text(fit3). section 5.8
  • Select specific ANOVA diagnostics with plot(fit1, which = c(2, 1)) instead of displaying all four plots. section 14.5.2

Checking an ANOVA model

After fitting fit1 <- aov(z_wins ~ o_pts_cat, data = nba_stats), run plot(fit1, which = c(2, 1)). The resulting Residuals vs. Fitted and Normal QQ plots help assess equal variances and normally distributed residuals; unequal dispersion at the highest fitted values suggests a possible, though not severe, variance violation. section 14.5.2

par(mfrow = c(2, 2))
plot(fit1)

View the compact R pattern for arranging and generating a four-panel model-diagnostic display. section 5.7.5

How Statistics Slam Dunk covers it

How deep it goes
Explains diagnostic plot meanings and selection, but stops short of detailing plot internals or generic dispatch.
Examples
Demonstrates four-panel regression diagnostics, selected ANOVA plots, and labeled regression-tree visualization.
What it assumes
Assumes a fitted regression, ANOVA, or tree model and basic familiarity with residuals, fitted values, and model assumptions.
What you can do after
Diagnose model assumptions with base R plots and visualize fitted regression trees with branch labels.
How it connects
Connects linear regression, residuals, normality, homoscedasticity, ANOVA, and regression trees.

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.