Learn R Programming

quadrupen (version 0.2-4)

plot,quadrupen-method: Plot method for a quadrupen object

Description

Produce a plot of the solution path of a quadrupen fit.

Usage

\S4method{plot}{quadrupen}(x, y, xvar = "lambda", main = paste(slot(x, "penalty")," path", sep=""), log.scale = TRUE, standardize=TRUE, reverse=FALSE, labels = NULL, plot = TRUE, ...)

Arguments

x
output of a fitting procedure of the quadrupen package (elastic.net or bounded.reg for the moment). Must be of class quadrupen.
y
used for S4 compatibility.
xvar
variable to plot on the X-axis: either "lambda" ($lambda1$ penalty level) or "fraction" ($l1$-norm of the coefficients). Default is set to "lambda".
main
the main title. Default is set to the model name followed by what is on the Y-axis.
log.scale
logical; indicates if a log-scale should be used when xvar="lambda". Default is TRUE.
standardize
logical; standardize the coefficients before plotting (with the norm of the predictor). Default is TRUE.
reverse
logical; should the X-axis be reversed when xvar="lambda"? Default is FALSE.
labels
vector indicating the names associated to the plotted variables. When specified, a legend is drawn in order to identify each variable. Only relevant when the number of predictor is small. Remind that the intercept does not count. Default is NULL.
plot
logical; indicates if the graph should be plotted on call. Default is TRUE.
...
Arguments to be passed to methods, such as graphical parameters (see par). Many methods will accept the following arguments:
type
what type of plot should be drawn. Possible types are
  • "p" for points,
  • "l" for lines,
  • "b" for both,
  • "c" for the lines part alone of "b",
  • "o" for both ‘overplotted’,
  • "h" for ‘histogram’ like (or ‘high-density’) vertical lines,
  • "s" for stair steps,
  • "S" for other steps, see ‘Details’ below,
  • "n" for no plotting.
All other types give a warning or an error; using, e.g., type = "punkte" being equivalent to type = "p" for S compatibility. Note that some methods, e.g. plot.factor, do not accept this.
main
an overall title for the plot: see title.
sub
a sub title for the plot: see title.

xlab
a title for the x axis: see title.
ylab
a title for the y axis: see title.
asp
the $y/x$ aspect ratio, see plot.window.

Value

a ggplot2 object which can be plotted via the print method.

See Also

quadrupen.

Examples

Run this code
## Not run: 
# ## Simulating multivariate Gaussian with blockwise correlation
# ## and piecewise constant vector of parameters
# beta <- rep(c(0,1,0,-1,0), c(25,10,25,10,25))
# cor <- 0.75
# Soo <- toeplitz(cor^(0:(25-1))) ## Toeplitz correlation for irrelevant variables
# Sww  <- matrix(cor,10,10) ## bloc correlation between active variables
# Sigma <- bdiag(Soo,Sww,Soo,Sww,Soo)
# diag(Sigma) <- 1
# n <- 50
# x <- as.matrix(matrix(rnorm(95*n),n,95) %*% chol(Sigma))
# y <- 10 + x %*% beta + rnorm(n,0,10)
# 
# ## Plot the Lasso path
# plot(elastic.net(x,y, lambda2=0), main="Lasso solution path")
# ## Plot the Elastic-net path
# plot(enet, main = "Elastic-net solution path")
# ## Plot the Elastic-net path (fraction on X-axis, unstandardized coefficient)
# plot(elastic.net(x,y, lambda2=10), standardize=FALSE, xvar="fraction")
# ## Plot the Bounded regression path (fraction on X-axis)
# plot(bounded.reg(x,y, lambda2=10), xvar="fraction")
# ## End(Not run)

Run the code above in your browser using DataLab