Skip to contents

Apply a regularized (generalized) linear model in parallel across each response $y$ in an outcome or mediation model. This can be helpful when we have many mediators or pretreatment variables, making the input high-dimensional.

Usage

glmnet_model(progress = TRUE, ...)

Arguments

progress

A logical indicating whether to show a progress bar during estimation.

...

Keyword parameters passed to package 'glmnet'.

Value

model An object of class model with estimator, predictor, and sampler functions associated wtih a lienar model.

See also

model lm_model rf_model

Examples

exper <- demo_joy() |>
    mediation_data("PHQ", "treatment", starts_with("ASV"))
multimedia(exper, glmnet_model(lambda = 1)) |>
    estimate(exper)
#> [Multimedia Analysis] 
#> Treatments: treatment 
#> Outcomes: PHQ 
#> Mediators: ASV1, ASV2, ... 
#>   
#> [Models] 
#> mediation: A fitted lm_model(). 
#> outcome: A fitted glmnet_model(). 

multimedia(exper, glmnet_model(lambda = 1), glmnet_model()) |>
    estimate(exper)
#> [Multimedia Analysis] 
#> Treatments: treatment 
#> Outcomes: PHQ 
#> Mediators: ASV1, ASV2, ... 
#>   
#> [Models] 
#> mediation: A fitted glmnet_model(). 
#> outcome: A fitted glmnet_model(). 

# example with another dataset
exper <- demo_spline(tau = c(2, 1)) |>
    mediation_data(starts_with("outcome"), "treatment", "mediator")
multimedia(exper, glmnet_model(lambda = 0.1)) |>
    estimate(exper)
#> [Multimedia Analysis] 
#> Treatments: treatment 
#> Outcomes: outcome_1, outcome_2 
#> Mediators: mediator 
#>   
#> [Models] 
#> mediation: A fitted lm_model(). 
#> outcome: A fitted glmnet_model().