plot.quadrupen: Plot method for a quadrupen object

plot,quadrupen-methodR Documentation

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" (\lambda_1 penalty level) or "fraction" (\ell_1-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.

...

Not used

Value

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

See Also

quadrupen.

Examples

## 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(elastic.net(x,y, lambda2=10), xvar = "lambda")
## 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")


jchiquet/quadrupenCRAN documentation built on Feb. 1, 2024, 9:56 p.m.