regularization_plot: Plots coefficients from regularizing various models.

Description Usage Arguments Value Examples

Description

Plots coefficients from regularizing various models.

Usage

1
regularization_plot(model, lambda, tol = 1e-07, x, y)

Arguments

model:

String specifying lasso, ridge regression, or logistic regression with L2-regularization. Argument should be one of "lasso", "ridge", or "logistic".

lambda:

Vector of penalty constant(s) multiplying the regularization term. Larger value corresponds to stronger regularization.

tol:

Coefficients less than this will be treated as zero.

x:

n x d dataframe of features.

y:

n x 1 dataframe of response values.

Value

ggplot object. Plot returned depends on length of lambda. length(lambda)==1: Plot displays magnitude of model coefficients, where coefficients with magnitude less than 'tol' are treated as zero. length(lambda)>1: Plot displays counts of nonzero coefficients in each model, where coefficients with magnitude less than 'tol' are treated as zero.

Examples

1
2
3
4
5
X <- mtcars[-1]
Y <- data.frame(mtcars$mpg)

regularization_plot('ridge', lambda=2^c(1,0,1), x=X, y=Y)
regularization_plot('lasso', lambda=2, x=X, y=Y)

UBC-MDS/ezmodelR documentation built on May 25, 2019, 1:35 p.m.