plot.genlasso produces a plot of the coordinate
paths for objects of class "genlasso". This can be helpful for
visualizing the full solution path for small problems; however, for
moderate or large problems, the plot produced can be quite dense and
difficult to interpret. The function plot.trendfilter applies
to objects of class "trendfilter", and plots trend filtering
coefficients at a single value of lambda (or multiple
values, as specified by the user) as a function of their positions
(which, recall, are assumed to be evenly spaced if not specified).
The function plot.cv.trendfilter plots the output of
cv.trendfilter.## S3 method for class 'genlasso':
plot(x, type = c("primal", "dual", "both"), numbers = FALSE,
vlines = TRUE, xlab, ylab, ...)
## S3 method for class 'trendfilter':
plot(x, style = c("trend", "path"), lambda, nlam, df, xlab,
ylab, ...)
## S3 method for class 'cv.trendfilter':
plot(x, legendpos = "top", xlab, ylab, ...)plot.genlasso, "trendfilter" for
plot.trendfilter, and "cv.trendfilter" for
plot.cv.trendfilter).plot.genlasso, a character string, one of "primal",
"dual", or "both", indicating which solution path system(s) should
be plotted. Default is "primal".plot.genlasso,
a logical variable indicating if coordinate paths should be labeled
by their numbers. Default is FALSE.plot.genlasso,
a logical variable indicating if dashed lines should be drawn at
knots in the path, with black lines for hitting events, and red
lines for leaving events. Default is TRUE.plot.trendfilter,
a character string, either "trend" or "path". If "trend", then trend
filtering coefficients are plotted according to their position. If
"path", then a plot of the coordinate paths is produced with the
funplot.trendfilter,
these arguments work exactly as they do in
coef.genlasso, and they are used to specify which
solutions should be extracted and plotted from the computed plot.cv.trendfilter, a character string indicating the
position of the legend. Default is "top".plot.trendfilter, with style set to "trend", a
coefficient object is silently returned as specified by lambda,
nlam, or df.genlasso, trendfilter,
cv.trendfilter# Constant trend filtering (the 1d fused lasso)
set.seed(0)
n = 100
beta0 = rep(sample(1:10,5),each=n/5)
y = beta0 + rnorm(n,sd=0.8)
a = fusedlasso1d(y)
cv = cv.trendfilter(a)
plot(a,style="path")
plot(cv)
plot(a,lambda=cv$lambda.1se)Run the code above in your browser using DataLab