-
Notifications
You must be signed in to change notification settings - Fork 30
Adapt nuisance est for IV-type score (PLR) & new score IV-type for PLIV
#161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ng parameter where measure is set to NULL
… warning checks
…ollowed by positional arguments
suggest test for functional initializer for IV-type score
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @MalteKurz ,
thanks for the PR fixing the IV-type score for the PLR and implementing it for PLIV (case with 1 instrument and partialling out X).
I only have minor comments and have I suggestion for an additional test (5dfe618) covering the functional initialization of the PLIV partial X with score = "IV-type" .
Feel free to integrate this or to drop it as you like. The other changes only refer to the exception handling in case user provide ml_g with score = "partialling out" (no strong opinion on this) and a minor change to the format of the documentation
Overall this looks good and is ready to be merged (subject to anything you'd like to change)
Co-authored-by: PhilippBach <[email protected]>
Co-authored-by: PhilippBach <[email protected]>
Co-authored-by: PhilippBach <[email protected]>
…ore partialling out
|
@PhilippBach Thanks for the review. I adapted the code accordingly. Additionally, I also adapted the corresponding Python PR such that the newly introduced warning is also present there. I also checked your suggested new unit test: I opened a corresponding PR in order to integrate it into this PR and added a comment with a suggestion / extension, see #162. |
test for initializer with IV-type score PLIV
Unit test for functional initializer for PLIV
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good now. Thanks @MalteKurz for incorporating these additional changes
Description
PLR
score='partialling out'(Equation (4.4) in Chernozhukov et al. (2018)) are not affected by the changes in this PR. However, the naming of the nuisance parameter is changed fromml_gtoml_l(analogously predictionsg_hathave been renamed tol_hat, etc.) to be better in line with Chernozhukov et al. (2018). To make the transition to the new naming smooth, depreciation warnings have been added (see below for an overview of the API changes and examples for the depreciation warnings).score='IV-type'(Equation (4.3) in Chernozhukov et al. (2018)) the implementation now follows the approach described on pp. C31-C33 in Chernozhukov et al. (2018). This means that an initial estimate fortheta_0is obtained via the'partialling out'score. Then an estimate forg_0(X)is obtained by regressingY - theta_0 * DonX. Therefore, an additional learner (not needed to evaluate the score) needs to be provided, i.e., the nuisance functionl_0(X)(needed for the preliminarytheta_0estimate) is estimated with learnerml_landg_0(X)with learnerml_g. To make the transition to the new API (additional learner) smooth, depreciation warnings have been added (see below for an overview of the API changes and examples for the depreciation warnings). Especially, if onlyml_gis specified but notml_l, thenml_g = clone(ml_l)is being used and a warning is being thrown.PLIV
score='partialling out'(Equation (4.8) in Chernozhukov et al. (2018)) are not affected by the changes in this PR. However, the naming of the nuisance parameter is changed fromml_gtoml_l(analogously predictionsg_hattol_hat, etc.) to be better in line with Chernozhukov et al. (2018). To make the transition to the new naming smooth, depreciation warnings have been added (see below for examples).score='IV-type'(Equation (4.7) in Chernozhukov et al. (2018)) is now available for the PLIV model. The estimation of the nuisance parts follows the approach described on p. C33 in Chernozhukov et al. (2018). This means that an initial estimate fortheta_0is obtained via the'partialling out'score. Then an estimate forg_0(X)is obtained by regressingY - theta_0 * DonX. Therefore, two additional learners (not needed to evaluate the score) need to be provided, i.e., the nuisance functionsl_0(X)andr_0(X)(needed for the preliminarytheta_0estimate) are estimated with learnerml_landml_r.g_0(X)is estimated with learnerml_g.API changes
PLR
DoubleMLPLR$new(obj_dml_data, ml_g, ml_m [, ...])toDoubleMLPLR$new(obj_dml_data, ml_l, ml_m, ml_g [, ...]).score='partialling out'ml_l&ml_mare needed.score='IV-type'ml_l,ml_m&ml_g.function()s as scoreml_l&ml_mare mandatory andml_goptional.function()is provided asscore, it must be of the formfunction(y, d, l_hat, m_hat, g_hat, smpls)(previouslyfunction(y, d, g_hat, m_hat, smpls)).PLIV
DoubleMLPLIV$new(obj_dml_data, ml_g, ml_m, ml_r [, ...])toDoubleMLPLIV$new(obj_dml_data, ml_g, ml_m, ml_r, ml_g [, ...]).score='partialling out'ml_l,ml_m&ml_rare needed.score='IV-type'ml_l,ml_m,ml_r&ml_g.function()s as scoreml_l,ml_m&ml_rare mandatory andml_goptional.function()is provided asscore, it must be of the formfunction(y, z, d, l_hat, m_hat, r_hat, g_hat, smpls)(previouslyfunction(y, z, d, g_hat, m_hat, r_hat, smpls)).Depreciation warnings for the API changes for
DoubleMLPLRandDoubleMLPLIVscore='partialling out'and if the learners are provided as positional arguments, nothing changed.-- >Note however that, if, besides the learner, other arguments have also been provided as positional arguments, the changed API causes exceptions because the additional learner was added as fourth (PLR) / fifth (PLIV) argument
score='partialling out'and keyword argumentsml_gandml_m(old API naming), the learner provided forml_gis used forml_land a warning is issued.score='IV-type'and keyword argumentsml_gandml_m(old API naming), the learner provided forml_gis also used forml_land a warning is issued. (Note it is first redirected toml_land then cloned toml_g)score='IV-type'and only two learners as positional arguments, the learner provided forml_gis used forml_land a warning is issued.score='partialling out', the methodsset_ml_nuisance_paramsandtuneredirectml_gtoml_l.Miscellaneous
scoreis set to afunction(), it will in the future be called with keyword-arguments only (instead of positional arguments). This way is "safer" and in some way indirectly checks (up to a certain degree) that the signature of the function is as expected (see docu entry of the argumentscorefor the expected signature). This was implemented for all model classes PLR, PLIV, IRM & IIVMPR Checklist
R CMD checkand all (unit) tests (see our contributing guidelines for details).