Introduction to iilasso package

# knitr::opts_chunk$set(echo = TRUE)
library(iilasso)
library(MASS)

Preparation

First, we prepare a toy data.

# setting
set.seed(0)
X <- matrix(rnorm(200, mean=0, sd=1), nrow=20, ncol=10)
b <- matrix(c(1,0,-1,0,0,0,0,0,0,0), ncol=1)
y <- as.numeric(X %*% b + rnorm(10, mean=0, sd=0.1))

Modeling

We then model by IILasso with cross validation.

cv_fit <- cv_lasso(X, y, delta=0.1, seed=0)
fit <- cv_fit$fit
fit$beta[, cv_fit$lambda.min.index]
fit$beta[, cv_fit$lambda.1se.index]
plot_cv_lasso(cv_fit)
plot_lasso(fit)

Prediction

Finally, we output predictions (for training data in this case).

pr <- predict_lasso(fit, X, cv_fit$lambda.min)
plot(pr, y)


Try the iilasso package in your browser

Any scripts or data that you put into this service are public.

iilasso documentation built on May 2, 2019, 10:14 a.m.