glmnet_model: Regularized 'Glmnet' Model across Responses

View source: R/estimators.R

glmnet_modelR Documentation

Regularized 'Glmnet' Model across Responses

Description

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(exper, glmnet_model(lambda = 1), glmnet_model()) |>
    estimate(exper)

# 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 documentation built on Sept. 30, 2024, 9:28 a.m.