Get the coefficients from a fitted ptLasso model.
Value
Model coefficients. If model = "overall"
, this function returns the output of coef
. If model
is "individual" or "pretrain", this function returns a list containing the results of coef
for each group-specific model. If model = "all"
, this returns a list containing all (overall, individual and pretrain) coefficients.
Examples
# Train data
out = gaussian.example.data()
x = out$x; y=out$y; groups = out$group;
fit = ptLasso(x, y, groups = groups, family = "gaussian", type.measure = "mse")
# Get all model coefficients.
names(coef(fit))
#> [1] "individual" "pretrain" "overall"
coef(fit, model = "overall") # Overall model only
#> 125 x 1 sparse Matrix of class "dgCMatrix"
#> lambda.1se
#> (Intercept) -2.307774
#> groups2 -1.226325
#> groups3 2.084267
#> groups4 2.421749
#> groups5 -5.413357
#> 6.696258
#> 7.495847
#> 5.994498
#> 6.349846
#> 8.511716
#> 7.547739
#> 7.251902
#> 7.598820
#> 7.724000
#> 7.192878
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
length(coef(fit, model = "individual")) # List of coefficients for each group model
#> [1] 5
length(coef(fit, model = "pretrain")) # List of coefficients for each group model
#> [1] 5