`R/double_ml_pliv.R`

`DoubleMLPLIV.Rd`

Double machine learning for partially linear IV regression models.

R6::R6Class object inheriting from DoubleML.

Partially linear IV regression (PLIV) models take the form

\(Y - D\theta_0 = g_0(X) + \zeta\),

\(Z = m_0(X) + V\),

with \(E[\zeta|Z,X]=0\) and \(E[V|X] = 0\). \(Y\) is the outcome variable variable, \(D\) is the policy variable of interest and \(Z\) denotes one or multiple instrumental variables. The high-dimensional vector \(X = (X_1, \ldots, X_p)\) consists of other confounding covariates, and \(\zeta\) and \(V\) are stochastic errors.

Other DoubleML:
`DoubleMLIIVM`

,
`DoubleMLIRM`

,
`DoubleMLPLR`

,
`DoubleML`

`DoubleML::DoubleML`

-> `DoubleMLPLIV`

`partialX`

(

`logical(1)`

)

Indicates whether covariates \(X\) should be partialled out.`partialZ`

(

`logical(1)`

)

Indicates whether instruments \(Z\) should be partialled out.

`new()`

Creates a new instance of this R6 class.

DoubleMLPLIV$new( data, ml_g, ml_m, ml_r, partialX = TRUE, partialZ = FALSE, n_folds = 5, n_rep = 1, score = "partialling out", dml_procedure = "dml2", draw_sample_splitting = TRUE, apply_cross_fitting = TRUE )

`data`

(

`DoubleMLData`

)

The`DoubleMLData`

object providing the data and specifying the variables of the causal model.`ml_g`

(

`LearnerRegr`

,`character(1)`

)

An object of the class mlr3 regression learner to pass a learner, possibly with specified parameters, for example`lrn("regr.cv_glmnet", s = "lambda.min")`

. Alternatively, a`character(1)`

specifying the name of a mlr3 regression learner that is available in mlr3 or its extension packages mlr3learners or mlr3extralearners, for example`"regr.cv_glmnet"`

.

`ml_g`

refers to the nuisance function \(g_0(X) = E[Y|X]\).`ml_m`

(

`LearnerRegr`

,`character(1)`

)

An object of the class mlr3 regression learner to pass a learner, possibly with specified parameters, for example`lrn("regr.cv_glmnet", s = "lambda.min")`

. Alternatively, a`character(1)`

specifying the name of a mlr3 regression learner that is available in mlr3 or its extension packages mlr3learners or mlr3extralearners, for example`"regr.cv_glmnet"`

.

`ml_m`

refers to the nuisance function \(m_0(X) = E[Z|X]\).`ml_r`

(

`LearnerRegr`

,`character(1)`

)

An object of the class mlr3 regression learner to pass a learner, possibly with specified parameters, for example`lrn("regr.cv_glmnet", s = "lambda.min")`

. Alternatively, a`character(1)`

specifying the name of a mlr3 regression learner that is available in mlr3 or its extension packages mlr3learners or mlr3extralearners, for example`"regr.cv_glmnet"`

.

`ml_r`

refers to the nuisance function \(r_0(X) = E[D|X]\).`partialX`

(

`logical(1)`

)

Indicates whether covariates \(X\) should be partialled out. Default is`TRUE`

.`partialZ`

(

`logical(1)`

)

Indicates whether instruments \(Z\) should be partialled out. Default is`FALSE`

.`n_folds`

(

`integer(1)`

)

Number of folds. Default is`5`

.`n_rep`

(

`integer(1)`

)

Number of repetitions for the sample splitting. Default is`1`

.`score`

(

`character(1)`

,`function()`

)

A`character(1)`

(`"partialling out"`

is the only choice) or a`function()`

specifying the score function. If a`function()`

is provided, it must be of the form`function(y, z, d, g_hat, m_hat, r_hat, smpls)`

and the returned output must be a named`list()`

with elements`psi_a`

and`psi_b`

. Default is`"partialling out"`

.`dml_procedure`

(

`character(1)`

)

A`character(1)`

(`"dml1"`

or`"dml2"`

) specifying the double machine learning algorithm. Default is`"dml2"`

.`draw_sample_splitting`

(

`logical(1)`

)

Indicates whether the sample splitting should be drawn during initialization of the object. Default is`TRUE`

.`apply_cross_fitting`

(

`logical(1)`

)

Indicates whether cross-fitting should be applied. Default is`TRUE`

.

`clone()`

The objects of this class are cloneable with this method.

DoubleMLPLIV$clone(deep = FALSE)

`deep`

Whether to make a deep clone.

# \donttest{ library(DoubleML) library(mlr3) library(mlr3learners) library(data.table) set.seed(2) ml_g = lrn("regr.ranger", num.trees = 100, mtry = 20, min.node.size = 2, max.depth = 5) ml_m = ml_g$clone() ml_r = ml_g$clone() obj_dml_data = make_pliv_CHS2015(alpha = 1, n_obs = 500, dim_x = 20, dim_z = 1) dml_pliv_obj = DoubleMLPLIV$new(obj_dml_data, ml_g, ml_m, ml_r) dml_pliv_obj$fit() dml_pliv_obj$summary()#> [1] "Estimates and significance testing of the effect of target variables" #> Estimate. Std. Error t value Pr(>|t|) #> d 0.9722 0.1032 9.418 <2e-16 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #># } if (FALSE) { library(DoubleML) library(mlr3) library(mlr3learners) library(mlr3tuning) library(data.table) set.seed(2) ml_g = lrn("regr.rpart") ml_m = ml_g$clone() ml_r = ml_g$clone() obj_dml_data = make_pliv_CHS2015( alpha = 1, n_obs = 500, dim_x = 20, dim_z = 1) dml_pliv_obj = DoubleMLPLIV$new(obj_dml_data, ml_g, ml_m, ml_r) param_grid = list( "ml_g" = paradox::ParamSet$new(list( paradox::ParamDbl$new("cp", lower = 0.01, upper = 0.02), paradox::ParamInt$new("minsplit", lower = 1, upper = 2))), "ml_m" = paradox::ParamSet$new(list( paradox::ParamDbl$new("cp", lower = 0.01, upper = 0.02), paradox::ParamInt$new("minsplit", lower = 1, upper = 2))), "ml_r" = paradox::ParamSet$new(list( paradox::ParamDbl$new("cp", lower = 0.01, upper = 0.02), paradox::ParamInt$new("minsplit", lower = 1, upper = 2)))) # minimum requirements for tune_settings tune_settings = list( terminator = mlr3tuning::trm("evals", n_evals = 5), algorithm = mlr3tuning::tnr("grid_search", resolution = 5)) dml_pliv_obj$tune(param_set = param_grid, tune_settings = tune_settings) dml_pliv_obj$fit() dml_pliv_obj$summary() }