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.333542
#> groups2 -1.176982
#> groups3 2.184525
#> groups4 2.632415
#> groups5 -5.340553
#> 6.739073
#> 7.657666
#> 6.096106
#> 6.309123
#> 8.605630
#> 7.535845
#> 7.214832
#> 7.635445
#> 7.697436
#> 7.149646
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
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