Produce a plot of a lars fit. The default is a complete coefficient path.
# S3 method for lars
plot(x, xvar= c("norm", "df", "arc.length", "step"), breaks = TRUE,
plottype = c("coefficients", "Cp"), omit.zeros = TRUE, eps = 1e-10, ...)
lars object
The type of x variable against which to
plot. xvar=norm
(default) plots against the L1 norm of the coefficient
vector, as a fraction of the maximal L1 norm. xvar=step
plots against the step number (which is
essentially degrees of freedom for LAR; not for LASSO or Forward
Stagewise). xvar=arc.length
plots against the arc.length of the
fitted vector; this is useful for a LAR object, because the L1 norm of
its coefficient vector need not be monotone in the steps.
xvar=df
plots against the estimated df, which is the size of the
active set at each step.
If TRUE
, then vertical lines are drawn at each
break point in the piecewise linear coefficient paths
Either coefficients
(default) or Cp
. The
coefficient plot shows the path of each coefficient as a function
of the norm fraction or Df. The Cp plot shows the Cp curve.
When the number of variables is much greater than
the number of observations, many coefficients will never be nonzero;
this logical (default TRUE
) avoids plotting these zero coefficents
Definition of zero above, default is 1e-10
Additonal arguments for generic plot. Can be used to set xlims, change colors, line widths, etc
NULL
The default plot uses the fraction of L1 norm as the xvar. For forward stagewise and LAR, coefficients can pass through zero during a step, which causes a change of slope of L1 norm vs arc-length. Since the coefficients are piecewise linear in arc-length between each step, this causes a change in slope of the coefficients.
Efron, Hastie, Johnstone and Tibshirani (2003) "Least Angle Regression" (with discussion) Annals of Statistics; see also https://hastie.su.domains/Papers/LARS/LeastAngle_2002.pdf. Yann-Ael Le Borgne (private communication) pointed out the problems in plotting forward stagewise and LAR coefficients against L1 norm, and the solution we have implemented.
# NOT RUN {
data(diabetes)
attach(diabetes)
object <- lars(x,y)
plot(object)
detach(diabetes)
# }
Run the code above in your browser using DataLab