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]

Methods

__init__(cate_estimator)

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 ((n, d_x) matrix, optional) – Features for each sample

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

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

  • outcome_names (list, optional) – Name of the outcome

  • treatment_names (list, optional) – Name of the treatment

  • feature_names (list, optional) – Name of the features

  • confounder_names (list, optional) – Name of the confounders

  • instrument_names (list, optional) – Name of the instruments

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

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

  • proceed_when_unidentifiable (bool, default True) – Whether the identification should proceed by ignoring potential unobserved confounders

  • missing_nodes_as_confounders (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 (scalar, default 0) – Value of the treatment in the control group, for effect estimation

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

  • target_units (str or obj, 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 (dict, optional) – Other keyword arguments from fit method for CATE estimator

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 (str) – Name of the refutation method

  • kwargs (dict, 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