Learn R Programming

robustHD (version 0.3.0)

plot.seqModel: Plot a sequence of regression models

Description

Produce a plot of the coefficients, the values of the optimality criterion, or diagnostic plots for a sequence of regression models, such as submodels along a robust least angle regression sequence, or sparse least trimmed squares regression models for a grid of values for the penalty parameter.

Usage

## S3 method for class 'seqModel':
plot(x,
    method = c("coefficients", "crit", "diagnostic"), ...)

  ## S3 method for class 'perrySeqModel':
plot(x,
    method = c("crit", "diagnostic"), ...)

  ## S3 method for class 'sparseLTS':
plot(x,
    method = c("coefficients", "crit", "diagnostic"), ...)

  ## S3 method for class 'perrySparseLTS':
plot(x,
    method = c("crit", "diagnostic"), ...)

Arguments

x
the model fit to be plotted.
method
a character string specifying the type of plot. Possible values are "coefficients" to plot the coefficients from the submodels via coefPlot (only for the "seqModel" a
...
additional arguments to be passed down.

Value

  • An object of class "ggplot" (see ggplot).

See Also

coefPlot, critPlot, diagnosticPlot, rlars, sparseLTS

Examples

Run this code
## generate data
# example is not high-dimensional to keep computation time low
library("mvtnorm")
set.seed(1234)  # for reproducibility
n <- 100  # number of observations
p <- 25   # number of variables
beta <- rep.int(c(1, 0), c(5, p-5))  # coefficients
sigma <- 0.5      # controls signal-to-noise ratio
epsilon <- 0.1    # contamination level
Sigma <- 0.5^t(sapply(1:p, function(i, j) abs(i-j), 1:p))
x <- rmvnorm(n, sigma=Sigma)    # predictor matrix
e <- rnorm(n)                   # error terms
i <- 1:ceiling(epsilon*n)       # observations to be contaminated
e[i] <- e[i] + 5                # vertical outliers
y <- c(x %*% beta + sigma * e)  # response
x[i,] <- x[i,] + 5              # bad leverage points


## robust LARS
# fit model
fitRlars <- rlars(x, y, sMax = 10)
# create plots
plot(fitRlars, method = "coef")
plot(fitRlars, method = "crit")
plot(fitRlars, method = "diagnostic")


## sparse LTS over a grid of values for lambda
# fit model
frac <- seq(0.2, 0.05, by = -0.05)
fitSparseLTS <- sparseLTS(x, y, lambda = frac, mode = "fraction")
# create plots
plot(fitSparseLTS, method = "coef")
plot(fitSparseLTS, method = "crit")
plot(fitSparseLTS, method = "diagnostic")

Run the code above in your browser using DataLab