modcheck: Model checking plots

View source: R/modcheck.R

modcheckR Documentation

Model checking plots

Description

Plots four model checking plots: an pred-res plot (residuals against predicted values), a Normal Quantile-Quantile (Q-Q) plot, a histogram of the residuals with a normal distribution super-imposed and a Cook's Distance plot.

Usage

modcheck(x, ...)

## S3 method for class 'lm'
modcheck(
  x,
  plotOrder = 1:4,
  args = list(eovcheck = list(smoother = FALSE, twosd = FALSE, levene = FALSE, ...),
    normcheck = list(xlab = c("Theoretical Quantiles", ""), ylab = c("Sample Quantiles",
    ""), main = c("", ""), col = "light blue", bootstrap = FALSE, B = 5, bpch = 3, bcol =
    "lightgrey", shapiro.wilk = FALSE, whichPlot = 1:2, usePar = TRUE, ...), cooks20x =
    list(main = "Cook's Distance plot", xlab = "observation number", ylab =
    "Cook's distance", line = c(0.5, 0.1, 2), cex.labels = 1, axisOpts = list(xAxis =
    TRUE), ...)),
  parVals = list(mfrow = c(2, 2), xaxs = "r", yaxs = "r", pty = "s", mai = c(0.2, 0.2,
    0.05, 0.05)),
  ...
)

Arguments

x

a vector of observations, or the residuals from fitting a linear model. Alternatively, a fitted lm object. If x is a single vector, then the implicit assumption is that the mean (or null) model is being fitted, i.e. lm(x ~ 1) and that the data are best summarised by the sample mean.

plotOrder

the order of the plots. 1: pred-res plot, 2: normal Q-Q plot, 3: histogram, 4: Cooks's Distance plot.

args

a list containing three additional lists eovcheckArgs, normcheckArgs and cooksArgs. The elements of these lists are the optional arguments of eovcheck, normcheck and cooks20x, and are explained in more detail in those functions. Most users will never use these arguments, but they provide super-flexibility in terms of what is displayed.

parVals

the values that are set via par for this plot. These are mfrow, xaxs, yaxs, pty, and mai. Most users will never use these arguments, but they provide super-flexibility in terms of what is displayed.

...

additional paramaters. Included for future flexibility, but unsure how this might be used currently.

Methods (by class)

  • modcheck(lm): Model checking plots

Examples


# An exponential growth curve
e = rnorm(100, 0, 0.1)
x = rnorm(100)
y = exp(5 + 3 * x + e)
fit = lm(y ~ x, data = data.frame(x, y))
modcheck(fit)

# An exponential growth curve with the correct transformation
fit = lm(log(y) ~ x, data = data.frame(x, y))
modcheck(fit)

# Peruvian Indians data
data(peru.df)
modcheck(lm(BP ~ weight, data = peru.df))


s20x documentation built on Aug. 21, 2023, 5:07 p.m.