- Notifications
You must be signed in to change notification settings - Fork 31
Description
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
doubleml-for-r/R/double_ml_plr.R
Lines 150 to 154 in acb9d46
| 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) |
doubleml-for-r/R/double_ml_irm.R
Lines 192 to 196 in acb9d46
| 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) |
doubleml-for-r/R/double_ml_iivm.R
Lines 248 to 254 in acb9d46
| 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
doubleml-for-r/R/double_ml_pliv.R
Lines 208 to 216 in acb9d46
| 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.
Line 1153 in acb9d46
| 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
Lines 162 to 166 in acb9d46
| if (task_type == "regr") { | |
| resp_name = "response" | |
| } else if (task_type == "classif") { | |
| resp_name = "prob.1" | |
| } |