Double machine learning data-backend.
DoubleMLData
objects can be initialized from a
data.table. Alternatively DoubleML
provides
functions to initialize from a collection of matrix
objects or
a data.frame
. The following functions can be used to create a new
instance of DoubleMLData
.
DoubleMLData$new()
for initialization from adata.table
.double_ml_data_from_matrix()
for initialization frommatrix
objects,double_ml_data_from_data_frame()
for initialization from adata.frame
.
Active bindings
all_variables
(
character()
)
All variables available in the dataset.d_cols
(
character()
)
The treatment variable(s).data
(
data.table
)
Data object.data_model
(
data.table
)
Internal data object that implements the causal model as specified by the user viay_col
,d_cols
,x_cols
andz_cols
.n_instr
(
NULL
,integer(1)
)
The number of instruments.n_obs
(
integer(1)
)
The number of observations.n_treat
(
integer(1)
)
The number of treatment variables.other_treat_cols
(
NULL
,character()
)
Ifuse_other_treat_as_covariate
isTRUE
,other_treat_cols
are the treatment variables that are not "active" in the multiple-treatment case. These variables then are internally added to the covariatesx_cols
during the fitting stage. Ifuse_other_treat_as_covariate
isFALSE
,other_treat_cols
isNULL
.treat_col
(
character(1)
)
"Active" treatment variable in the multiple-treatment case.use_other_treat_as_covariate
(
logical(1)
)
Indicates whether in the multiple-treatment case the other treatment variables should be added as covariates. Default isTRUE
.x_cols
(
NULL
,character()
)
The covariates. IfNULL
, all variables (columns ofdata
) which are neither specified as outcome variabley_col
, nor as treatment variablesd_cols
, nor as instrumental variablesz_cols
are used as covariates. Default isNULL
.y_col
(
character(1)
)
The outcome variable.z_cols
(
NULL
,character()
)
The instrumental variables. Default isNULL
.
Methods
Method new()
Creates a new instance of this R6 class.
Usage
DoubleMLData$new(
data = NULL,
x_cols = NULL,
y_col = NULL,
d_cols = NULL,
z_cols = NULL,
use_other_treat_as_covariate = TRUE
)
Arguments
data
(
data.table
,data.frame()
)
Data object.x_cols
(
NULL
,character()
)
The covariates. IfNULL
, all variables (columns ofdata
) which are neither specified as outcome variabley_col
, nor as treatment variablesd_cols
, nor as instrumental variablesz_cols
are used as covariates. Default isNULL
.y_col
(
character(1)
)
The outcome variable.d_cols
(
character()
)
The treatment variable(s).z_cols
(
NULL
,character()
)
The instrumental variables. Default isNULL
.use_other_treat_as_covariate
(
logical(1)
)
Indicates whether in the multiple-treatment case the other treatment variables should be added as covariates. Default isTRUE
.
Method set_data_model()
Setter function for data_model
. The function implements the causal
model as specified by the user via y_col
, d_cols
, x_cols
and
z_cols
and assigns the role for the treatment variables in the
multiple-treatment case.
Arguments
treatment_var
(
character()
)
Active treatment variable that will be set totreat_col
.
Examples
library(DoubleML)
df = make_plr_CCDDHNR2018(return_type = "data.table")
obj_dml_data = DoubleMLData$new(df,
y_col = "y",
d_cols = "d")