Skip to contents

Extract model coefficients from the final model in msaenet model objects.

Usage

# S3 method for class 'msaenet'
coef(object, ...)

Arguments

object

An object of class msaenet produced by aenet, amnet, asnet, msaenet, msamnet, or msasnet.

...

Additional parameters for coef (not used).

Value

A numerical vector of model coefficients.

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
)

coef(msaenet.fit)
#>   [1]  0.0000000  2.1657439  0.0000000  1.7619827  0.8366843  0.0000000
#>   [7]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#>  [13]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#>  [19]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#>  [25]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#>  [31]  0.0000000  0.0000000  0.0000000  0.0000000  0.8954118  0.0000000
#>  [37]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#>  [43]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#>  [49]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#>  [55]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#>  [61]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#>  [67]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#>  [73]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#>  [79]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#>  [85]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#>  [91]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#>  [97]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [103]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [109]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000 -0.3592967
#> [115]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [121]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [127]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [133]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [139]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [145]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [151]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [157]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [163]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [169]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [175]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [181]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [187]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [193]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [199]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [205]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [211]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [217]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [223]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [229]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [235]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [241]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [247]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [253]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [259]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [265]  0.0000000  0.0000000  0.0000000  0.0000000  0.7274414  0.0000000
#> [271]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [277]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [283]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [289]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [295]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [301]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [307]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [313]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [319]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [325]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [331]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [337]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [343]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [349]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [355]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [361]  0.0000000  0.0000000 -0.4787929  0.0000000  0.0000000  0.0000000
#> [367]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [373]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [379] -0.2787463  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [385]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [391]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [397]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [403]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [409]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [415]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [421]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [427]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [433]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [439]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [445]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [451]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [457]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [463]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [469]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [475]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [481]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [487]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [493]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
#> [499]  0.0000000  0.0000000