data(peru.df)
lmFit = lm(BP ~ weight, data = peru.df)
# Plot residuals versus fitted values only
modelcheck(lmFit, 1)
# Plot residuals versus fitted values, histogram, and Q-Q plot
modelcheck(lmFit, 1:2)
# Plot all diagnostics
modelcheck(lmFit)
# Optional ggplot2 engine for reusable plot objects
if (requireNamespace("ggplot2", quietly = TRUE)) {
diagnosticPlots = modelcheck(lmFit, engine = "ggplot2")
names(diagnosticPlots)
modelcheck(lmFit, which = 1, engine = "ggplot2")
modelcheck(lmFit, which = 2, engine = "ggplot2")
modelcheck(lmFit, which = 3, engine = "ggplot2")
}
Run the code above in your browser using DataLab