econml.dowhy.DoWhyWrapper

class econml.dowhy.DoWhyWrapper(cate_estimator)[source]

Bases: object

A wrapper class to allow user call other methods from dowhy package through EconML. (e.g. causal graph, refutation test, etc.)

Parameters

cate_estimator (instance) – An instance of any CATE estimator we currently support

__init__(cate_estimator)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(cate_estimator)

Initialize self.

fit(Y, T[, X, W, Z, outcome_names, …])

Estimate the counterfactual model from data through dowhy package.

refit_final([inference])

refute_estimate(*, method_name, **kwargs)

Refute an estimated causal effect.

fit(Y, T, X=None, W=None, Z=None, *, outcome_names=None, treatment_names=None, feature_names=None, confounder_names=None, instrument_names=None, graph=None, estimand_type='nonparametric-ate', proceed_when_unidentifiable=True, missing_nodes_as_confounders=False, control_value=0, treatment_value=1, target_units='ate', **kwargs)[source]

Estimate the counterfactual model from data through dowhy package.

Parameters
  • Y (vector of length n) – Outcomes for each sample

  • T (vector of length n) – Treatments for each sample

  • X (optional (n, d_x) matrix (Default=None)) – Features for each sample

  • W (optional (n, d_w) matrix (Default=None)) – Controls for each sample

  • Z (optional (n, d_z) matrix (Default=None)) – Instruments for each sample

  • outcome_names (optional list (Default=None)) – Name of the outcome

  • treatment_names (optional list (Default=None)) – Name of the treatment

  • feature_names (optional list (Default=None)) – Name of the features

  • confounder_names (optional list (Default=None)) – Name of the confounders

  • instrument_names (optional list (Default=None)) – Name of the instruments

  • graph (optional) – Path to DOT file containing a DAG or a string containing a DAG specification in DOT format

  • estimand_type (optional string) – Type of estimand requested (currently only “nonparametric-ate” is supported). In the future, may support other specific parametric forms of identification

  • proceed_when_unidentifiable (optional bool (Default=True)) – Whether the identification should proceed by ignoring potential unobserved confounders

  • missing_nodes_as_confounders (optional bool (Default=False)) – Whether variables in the dataframe that are not included in the causal graph should be automatically included as confounder nodes

  • control_value (optional scalar (Default=0)) – Value of the treatment in the control group, for effect estimation

  • treatment_value (optional scalar (Default=1)) – Value of the treatment in the treated group, for effect estimation

  • target_units (optional (Default=”ate”)) – The units for which the treatment effect should be estimated. This can be of three types:

    1. A string for common specifications of target units (namely, “ate”, “att” and “atc”),

    2. A lambda function that can be used as an index for the data (pandas DataFrame),

    3. A new DataFrame that contains values of the effect_modifiers and effect will be estimated only for this new data

  • kwargs (optional) – Other keyword arguments from fit method for CATE estimator

Returns

Return type

self

refute_estimate(*, method_name, **kwargs)[source]

Refute an estimated causal effect.

If method_name is provided, uses the provided method. In the future, we may support automatic selection of suitable refutation tests. Following refutation methods are supported:

  • Adding a randomly-generated confounder: “random_common_cause”

  • Adding a confounder that is associated with both treatment and outcome: “add_unobserved_common_cause”

  • Replacing the treatment with a placebo (random) variable): “placebo_treatment_refuter”

  • Removing a random subset of the data: “data_subset_refuter”

For more details, see docs dowhy.causal_refuters

Parameters
  • method_name (string) – Name of the refutation method

  • kwargs (optional) – Additional arguments that are passed directly to the refutation method. Can specify a random seed here to ensure reproducible results (‘random_seed’ parameter). For method-specific parameters, consult the documentation for the specific method. All refutation methods are in the causal_refuters subpackage.

Returns

RefuteResult

Return type

an instance of the RefuteResult class