Produces a Q-Q plot of residuals from a linear model to test for normality, optionally annotating outlier points and adding the Shapiro-Wilk test p-value.
Usage
lm_plot.qq(
mdl,
opt = list(),
parm = list(),
df = lm_plot.df(mdl),
plts = list()
)
Arguments
- mdl
A fitted model object (typically from
lm
).- opt
List of options, where
pval.SW
(logical, default = FALSE) indicates whether to include Shapiro-Wilk p-value on the plot.- parm
List of plotting parameters, usually from
lm_plot.parms()
.- df
Data frame with augmented model data. Defaults to
lm_plot.df(mdl)
.- plts
List of ggplot objects to which this plot will be added.
Value
A list containing:
mdl
Fitted model object,opt
Options used, includingpval.SW
,parm
Parameter list with Shapiro-Wilk test results added,df
Data frame used for plotting,plts
List of ggplot objects, including the$qq
element.
Details
The plot visualizes the distribution of residuals against theoretical normal quantiles. Points are colored and shaped by outlier status, and a reference Q-Q line is added. Optionally, outlier and regular points can be labeled. If enabled, the Shapiro-Wilk normality test p-value is displayed.