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]
##  [1]  0.943851959  0.011549660 -0.987093401  0.000000000  0.000000000
##  [6]  0.005475753 -0.017101833  0.000000000  0.033351469  0.017976365
fit$beta[, cv_fit$lambda.1se.index]
##  [1]  0.92024801  0.00000000 -0.95241105  0.00000000  0.00000000
##  [6]  0.00000000  0.00000000  0.00000000  0.00734411  0.00000000
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)