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
