Learn R Programming

india (version 0.1-2)

envelope: QQ-plot of residuals with simulated envelope

Description

Constructs a normal QQ-plot with simulated envelope of residuals from a fitted model object.

Usage

envelope(object, ...)
# S3 method for lm
envelope(object, reps = 50, conf = 0.95, 
  type = c("quantile", "standard", "student"), plot.it = TRUE, ...)
# S3 method for lad
envelope(object, reps = 50, conf = 0.95, plot.it = TRUE, ...)
# S3 method for ols
envelope(object, reps = 50, conf = 0.95, 
  type = c("quantile", "standard", "student"), plot.it = TRUE, ...)
# S3 method for nls
envelope(object, reps = 50, conf = 0.95, plot.it = TRUE, ...)
# S3 method for ridge
envelope(object, reps = 50, conf = 0.95, plot.it = TRUE, ...)

Value

a list containing the following elements:

residuals

a vector with the selected (see type argument) residuals.

envelope

a matrix with two columns corresponding to the values of the lower and upper pointwise confidence envelope.

Arguments

object

an R object, returned by lm, lad, ols, nls or ridge.

reps

number of simulated point patterns to be generated when computing the envelopes. The default number is 50, a larger number of replications will produce a smoother band, although it takes more time.

conf

the confidence level required for the construction of the envelope. The default is to find 95% confidence envelopes.

type

a character string indicating the type of residuals that should be used in the construction of the envelope. The available options are randomized quantile ("quantile"), standardized ("standard") and studentized ("student") residuals. Standardized and studentized residuals are only available for objects of class "lm" and "ols"; otherwise, quantile residuals are used.

plot.it

if TRUE it will draw the corresponding plot, if FALSE it will only return the computed values.

...

further arguments passed to or from other methods.

References

Atkinson, A.C. (1985). Plots, Transformations and Regression. Oxford University Press, Oxford.

Osorio, F. (2026). On the mean-shift outlier model for LAD regression. Working paper.

Venables, W.N., Ripley, B.D. (1999). Modern Applied Statistics with S-PLUS, 3rd Ed. Springer, New York.

Examples

Run this code
# QQ-plot with envelope for linear regression
fm <- ols(stack.loss ~ ., data = stackloss)
z <- envelope(fm, reps = 500)

# QQ-plot with envelope for LAD regression
data(ereturns)
fm <- lad(m.marietta ~ CRSP, data = ereturns)
z <- envelope(fm, reps = 500)

# QQ-plot with envelope for ridge regression
data(portland)
fm <- ridge(y ~ ., data = portland)
z <- envelope(fm, reps = 500)

# QQ-plot with envelope nonlinear regression
data(skeena)
model <- recruits ~ b1 * spawners * exp(-b2 * spawners)
fm <- nls(model, data = skeena, start = list(b1 = 3, b2 = 0))
z <- envelope(fm, reps = 500)

Run the code above in your browser using DataLab