Get the indices of non-zero variables from msaenet model objects.
Author
Nan Xiao <https://nanx.me>
Examples
dat <- msaenet.sim.gaussian(
n = 150, p = 500, rho = 0.6,
coef = rep(1, 5), snr = 2, p.train = 0.7,
seed = 1001
)
msaenet.fit <- msaenet(
dat$x.tr, dat$y.tr,
alphas = seq(0.2, 0.8, 0.2),
nsteps = 3L, seed = 1003
)
msaenet.nzv(msaenet.fit)
#> [1] 2 4 5 35 114 269 363 379
# coefficients of non-zero variables
coef(msaenet.fit)[msaenet.nzv(msaenet.fit)]
#> [1] 2.1657439 1.7619827 0.8366843 0.8954118 -0.3592967 0.7274414 -0.4787929
#> [8] -0.2787463