Generates a scatter plot of observed values versus fitted values from a linear model, with optional prediction intervals and identification of outlier points. The plot includes a reference line y = x
for assessing linearity.
Usage
lm_plot.fit(
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
pred_intvl_pts
(numeric, default = 100) is used for prediction interval bounds of fitted values (0 to skip).- 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, includingpred_intvl_pts
,parm
Parameter list with autocorrelation test results added,df
Data frame used for plotting,plts
List of ggplot objects, including the$fit
element.
Details
The plot visualizes observed versus fitted values, includes a diagonal reference line, marks outliers, and can optionally display loess-smoothed prediction intervals. Outlier and regular points can be labeled. This plot is useful for visually assessing linearity and model fit quality.