Skip to content

Bug when nonlinear lasso is used as learners_DX #73

Description

@hjuerges

Hello,

I think the prediction from a logit lasso should be set to type = "response". Otherwise the linear prediction of the link function is used which leads to massive trimming. See example below.

But otherwise, thanks for writing this package in R. I am trying to find an easily accessible double machine learning function in R for my students, and I think this could be it.

Kind regards
Hendrik


library(ddml)

Construct variables from the included Angrist & Evans (1998) data

y = AE98[, "worked"]
D = AE98[, "morekids"]
X = AE98[, c("age","agefst","black","hisp","othrace","educ")]

Estimate the average treatment effect using linear lasso in the Y and the D Model

ate_fit <- ddml_ate(y, D, X,
learners = list(what = mdl_glmnet,
args = list(alpha = 1)),
sample_folds = 2,
silent = TRUE)
summary(ate_fit)

Estimate the average treatment effect using a logit for the D model

ate_fit <- ddml_ate(y, D, X,
learners = list(what = mdl_glmnet,
args = list(alpha = 1)),
learners_DX = list(what = mdl_glmnet,
args = list(family = "binomial")),
sample_folds = 2,
silent = TRUE)
summary(ate_fit)

Activity

  1. thomaswiemann commented on May 4, 2025

    @thomaswiemann
    Owner

    Hi @hjuerges -- thanks for highlighting this issue with mdl_glmnet! We fixed this issue in commit 9cd0959 a while ago (see also the chanellog). To avoid this issue, please install the package via devtools::install_github("thomaswiemann/ddml", dependencies = TRUE). This installs the dev version. We will update the cran version later this summer to fix the issue there as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions