Get the coefficients from a fitted ptLasso model.
coef.ptLasso.Rd
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.052054138
#> groups2 -5.257341078
#> groups3 -2.389391227
#> groups4 -1.437556849
#> groups5 -3.271465840
#> 7.211333045
#> 6.169574950
#> 7.153849839
#> 7.889874136
#> 6.125555277
#> 6.346236366
#> 6.576249202
#> 8.656569346
#> 7.089373251
#> 6.657026317
#> .
#> .
#> .
#> .
#> .
#> .
#> 0.247979836
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> 0.006040405
#> .
#> .
#> .
#> .
#> 1.077105440
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
#> .
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