Supplement the fitted values and residuals of a sequence of regression models (such as robust least angle regression models or sparse least trimmed squares regression models) with other useful information for diagnostic plots.
1 2 3 4 5 6 
model 
the model fit to be converted. 
data 
currently ignored. 
s 
for the 
covArgs 
a list of arguments to be passed to

fit 
a character string specifying which fit to convert. Possible
values are 
... 
additional arguments to be passed to

A data frame containing the columns listed below, as well as
additional information stored in the attributes "qqLine"
(intercepts
and slopes of the respective reference lines to be displayed in residual QQ
plots), "q"
(quantiles of the Mahalanobis distribution used as cutoff
points for detecting leverage points), and "facets"
(default faceting
formula for the diagnostic plots).
step 
the steps (for the 
fit 
the model fits (only returned if both the reweighted
and raw fit are requested in the 
index 
the indices of the observations. 
fitted 
the fitted values. 
residual 
the standardized residuals. 
theoretical 
the corresponding theoretical quantiles from the standard normal distribution. 
qqd 
the absolute distances from a reference line through the first and third sample and theoretical quartiles. 
rd 
the robust Mahalanobis distances computed via the MCD (see

xyd 
the pairwise maxima of the absolute values of the standardized residuals and the robust Mahalanobis distances, divided by the respective other outlier detection cutoff point. 
weight 
the weights indicating regression outliers. 
leverage 
logicals indicating leverage points (i.e., outliers in the predictor space). 
classification 
a factor with levels 
Andreas Alfons
fortify
, diagnosticPlot
,
sparseLTS
, sparseLTS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  ## generate data
# example is not highdimensional 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, p5)) # coefficients
sigma < 0.5 # controls signaltonoise ratio
epsilon < 0.1 # contamination level
Sigma < 0.5^t(sapply(1:p, function(i, j) abs(ij), 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)
# convert to data for plotting
head(fortify(fitRlars))
## sparse LTS
# fit model
fitSparseLTS < sparseLTS(x, y, lambda = 0.05, mode = "fraction")
# convert to data for plotting
head(fortify(fitSparseLTS))
head(fortify(fitSparseLTS, fit = "both"))

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.