Skip to content

Inconsistent initilization of task_type between PLIV and other models (PLR, IRM, IIVM) #157

@MalteKurz

Description

@MalteKurz

PLR, IRM and IIVM

For PLR, IRM and IIVM, we first initialize the private property task_type to NULL for all necessary nuisance parts and during the call to assert_learner it is filled up with content. See

private$task_type = list(
"ml_g" = NULL,
"ml_m" = NULL)
ml_g = private$assert_learner(ml_g, "ml_g", Regr = TRUE, Classif = FALSE)
ml_m = private$assert_learner(ml_m, "ml_m", Regr = TRUE, Classif = TRUE)

private$task_type = list(
"ml_g" = NULL,
"ml_m" = NULL)
ml_g = private$assert_learner(ml_g, "ml_g", Regr = TRUE, Classif = TRUE)
ml_m = private$assert_learner(ml_m, "ml_m", Regr = FALSE, Classif = TRUE)

private$task_type = list(
"ml_g" = NULL,
"ml_m" = NULL,
"ml_r" = NULL)
ml_g = private$assert_learner(ml_g, "ml_g", Regr = TRUE, Classif = TRUE)
ml_m = private$assert_learner(ml_m, "ml_m", Regr = FALSE, Classif = TRUE)
ml_r = private$assert_learner(ml_r, "ml_r", Regr = FALSE, Classif = TRUE)

PLIV

For PLIV this initialization does not happen, but still it seems to work as expected, see

ml_g = private$assert_learner(ml_g, "ml_g",
Regr = TRUE,
Classif = FALSE)
ml_m = private$assert_learner(ml_m, "ml_m",
Regr = TRUE,
Classif = FALSE)
ml_r = private$assert_learner(ml_r, "ml_r",
Regr = TRUE,
Classif = FALSE)

Possible solution

In the base class DoubleML the private property task_type is initialized to an empty list, which in my view suffices.

task_type = list(),

It is then filled up with meaningful content when assert_learner is being called for the learners assigned for the different nuisance parts. Therefore, I guess we could simplify by removing the additional nuisance-part specific initialization to NULL being done for PLR, IRM and IIVM.

Miscellaneous

I would furthermore would suggest to add some sort of assertion in the helper function dml_cv_predict. Basically, I wouldn't accept something else than "regr" or "classif". The code will anyways fail with any other choice, like NULL, because then variable resp_name would never be assigned, see

doubleml-for-r/R/helper.R

Lines 162 to 166 in acb9d46

if (task_type == "regr") {
resp_name = "response"
} else if (task_type == "classif") {
resp_name = "prob.1"
}

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions