dowhy.causal_estimators package
Submodules
dowhy.causal_estimators.econml_cate_estimator module
- class dowhy.causal_estimators.econml_cate_estimator.EconmlCateEstimator(*args, **kwargs)[source]
Bases:
CausalEstimator
Initializes an estimator with data and names of relevant variables.
More description.
- Parameters
data – data frame containing the data
identified_estimand – probability expression representing the target identified estimand to estimate.
treatment – name of the treatment variable
outcome – name of the outcome variable
control_value – Value of the treatment in the control group, for effect estimation. If treatment is multi-variate, this can be a list.
treatment_value – Value of the treatment in the treated group, for effect estimation. If treatment is multi-variate, this can be a list.
test_significance – whether to test significance
evaluate_effect_strength – (Experimental) whether to evaluate the strength of effect
confidence_intervals – (Experimental) Binary flag indicating whether confidence intervals should be computed.
target_units – (Experimental) The units for which the treatment effect should be estimated. This can be a string for common specifications of target units (namely, “ate”, “att” and “atc”). It can also be a lambda function that can be used as an index for the data (pandas DataFrame). Alternatively, it can be a new DataFrame that contains values of the effect_modifiers and effect will be estimated only for this new data.
effect_modifiers – variables on which to compute separate effects, or return a heterogeneous effect function. Not all methods support this currently.
params – (optional) additional method parameters
- Returns
an instance of the estimator class.
dowhy.causal_estimators.instrumental_variable_estimator module
- class dowhy.causal_estimators.instrumental_variable_estimator.InstrumentalVariableEstimator(*args, **kwargs)[source]
Bases:
CausalEstimator
Compute effect of treatment using the instrumental variables method.
This is also a superclass that can be inherited by other specific methods.
Supports additional parameters that can be specified in the estimate_effect() method.
‘iv_instrument_name’: Name of the specific instrumental variable to be used. Needs to be one of the IVs identified in the identification step. Default is to use all the IV variables from the identification step.
Initializes an estimator with data and names of relevant variables.
More description.
- Parameters
data – data frame containing the data
identified_estimand – probability expression representing the target identified estimand to estimate.
treatment – name of the treatment variable
outcome – name of the outcome variable
control_value – Value of the treatment in the control group, for effect estimation. If treatment is multi-variate, this can be a list.
treatment_value – Value of the treatment in the treated group, for effect estimation. If treatment is multi-variate, this can be a list.
test_significance – whether to test significance
evaluate_effect_strength – (Experimental) whether to evaluate the strength of effect
confidence_intervals – (Experimental) Binary flag indicating whether confidence intervals should be computed.
target_units – (Experimental) The units for which the treatment effect should be estimated. This can be a string for common specifications of target units (namely, “ate”, “att” and “atc”). It can also be a lambda function that can be used as an index for the data (pandas DataFrame). Alternatively, it can be a new DataFrame that contains values of the effect_modifiers and effect will be estimated only for this new data.
effect_modifiers – variables on which to compute separate effects, or return a heterogeneous effect function. Not all methods support this currently.
params – (optional) additional method parameters
- Returns
an instance of the estimator class.
dowhy.causal_estimators.linear_regression_estimator module
- class dowhy.causal_estimators.linear_regression_estimator.LinearRegressionEstimator(*args, **kwargs)[source]
Bases:
CausalEstimator
Compute effect of treatment using linear regression.
Fits a regression model for estimating the outcome using treatment(s) and confounders. For a univariate treatment, the treatment effect is equivalent to the coefficient of the treatment variable.
Demo method to show the implementation of a causal inference method that can handle multiple treatments and heterogeneity in treatment. Requires a strong assumption that all relationships from (T, W) to Y are linear.
Common method but the assumptions required are too strong.
Initializes an estimator with data and names of relevant variables.
More description.
- Parameters
data – data frame containing the data
identified_estimand – probability expression representing the target identified estimand to estimate.
treatment – name of the treatment variable
outcome – name of the outcome variable
control_value – Value of the treatment in the control group, for effect estimation. If treatment is multi-variate, this can be a list.
treatment_value – Value of the treatment in the treated group, for effect estimation. If treatment is multi-variate, this can be a list.
test_significance – whether to test significance
evaluate_effect_strength – (Experimental) whether to evaluate the strength of effect
confidence_intervals – (Experimental) Binary flag indicating whether confidence intervals should be computed.
target_units – (Experimental) The units for which the treatment effect should be estimated. This can be a string for common specifications of target units (namely, “ate”, “att” and “atc”). It can also be a lambda function that can be used as an index for the data (pandas DataFrame). Alternatively, it can be a new DataFrame that contains values of the effect_modifiers and effect will be estimated only for this new data.
effect_modifiers – variables on which to compute separate effects, or return a heterogeneous effect function. Not all methods support this currently.
params – (optional) additional method parameters
- Returns
an instance of the estimator class.
dowhy.causal_estimators.propensity_score_matching_estimator module
- class dowhy.causal_estimators.propensity_score_matching_estimator.PropensityScoreMatchingEstimator(*args, **kwargs)[source]
Bases:
CausalEstimator
Initializes an estimator with data and names of relevant variables.
More description.
- Parameters
data – data frame containing the data
identified_estimand – probability expression representing the target identified estimand to estimate.
treatment – name of the treatment variable
outcome – name of the outcome variable
control_value – Value of the treatment in the control group, for effect estimation. If treatment is multi-variate, this can be a list.
treatment_value – Value of the treatment in the treated group, for effect estimation. If treatment is multi-variate, this can be a list.
test_significance – whether to test significance
evaluate_effect_strength – (Experimental) whether to evaluate the strength of effect
confidence_intervals – (Experimental) Binary flag indicating whether confidence intervals should be computed.
target_units – (Experimental) The units for which the treatment effect should be estimated. This can be a string for common specifications of target units (namely, “ate”, “att” and “atc”). It can also be a lambda function that can be used as an index for the data (pandas DataFrame). Alternatively, it can be a new DataFrame that contains values of the effect_modifiers and effect will be estimated only for this new data.
effect_modifiers – variables on which to compute separate effects, or return a heterogeneous effect function. Not all methods support this currently.
params – (optional) additional method parameters
- Returns
an instance of the estimator class.
dowhy.causal_estimators.propensity_score_stratification_estimator module
- class dowhy.causal_estimators.propensity_score_stratification_estimator.PropensityScoreStratificationEstimator(*args, num_strata=50, clipping_threshold=10, **kwargs)[source]
Bases:
CausalEstimator
Estimate effect of treatment by stratifying the data into bins with identical common causes.
Straightforward application of the back-door criterion.
Initializes an estimator with data and names of relevant variables.
More description.
- Parameters
data – data frame containing the data
identified_estimand – probability expression representing the target identified estimand to estimate.
treatment – name of the treatment variable
outcome – name of the outcome variable
control_value – Value of the treatment in the control group, for effect estimation. If treatment is multi-variate, this can be a list.
treatment_value – Value of the treatment in the treated group, for effect estimation. If treatment is multi-variate, this can be a list.
test_significance – whether to test significance
evaluate_effect_strength – (Experimental) whether to evaluate the strength of effect
confidence_intervals – (Experimental) Binary flag indicating whether confidence intervals should be computed.
target_units – (Experimental) The units for which the treatment effect should be estimated. This can be a string for common specifications of target units (namely, “ate”, “att” and “atc”). It can also be a lambda function that can be used as an index for the data (pandas DataFrame). Alternatively, it can be a new DataFrame that contains values of the effect_modifiers and effect will be estimated only for this new data.
effect_modifiers – variables on which to compute separate effects, or return a heterogeneous effect function. Not all methods support this currently.
params – (optional) additional method parameters
- Returns
an instance of the estimator class.
dowhy.causal_estimators.propensity_score_weighting_estimator module
- class dowhy.causal_estimators.propensity_score_weighting_estimator.PropensityScoreWeightingEstimator(*args, min_ps_score=0.05, max_ps_score=0.95, **kwargs)[source]
Bases:
CausalEstimator
Estimate effect of treatment by weighing the data by inverse probability of occurrence.
Straightforward application of the back-door criterion.
Supports additional parameters that can be specified in the estimate_effect() method.
‘weighting_scheme’: This is the name of weighting method to use. Can be inverse propensity score (“ips_weight”, default), stabilized IPS score (“ips_stabilized_weight”), or normalized IPS score (“ips_normalized_weight”)
Initializes an estimator with data and names of relevant variables.
More description.
- Parameters
data – data frame containing the data
identified_estimand – probability expression representing the target identified estimand to estimate.
treatment – name of the treatment variable
outcome – name of the outcome variable
control_value – Value of the treatment in the control group, for effect estimation. If treatment is multi-variate, this can be a list.
treatment_value – Value of the treatment in the treated group, for effect estimation. If treatment is multi-variate, this can be a list.
test_significance – whether to test significance
evaluate_effect_strength – (Experimental) whether to evaluate the strength of effect
confidence_intervals – (Experimental) Binary flag indicating whether confidence intervals should be computed.
target_units – (Experimental) The units for which the treatment effect should be estimated. This can be a string for common specifications of target units (namely, “ate”, “att” and “atc”). It can also be a lambda function that can be used as an index for the data (pandas DataFrame). Alternatively, it can be a new DataFrame that contains values of the effect_modifiers and effect will be estimated only for this new data.
effect_modifiers – variables on which to compute separate effects, or return a heterogeneous effect function. Not all methods support this currently.
params – (optional) additional method parameters
- Returns
an instance of the estimator class.
dowhy.causal_estimators.regression_discontinuity_estimator module
- class dowhy.causal_estimators.regression_discontinuity_estimator.RegressionDiscontinuityEstimator(*args, **kwargs)[source]
Bases:
CausalEstimator
Compute effect of treatment using the regression discontinuity method.
Estimates effect by transforming the problem to an instrumental variables problem.
Supports additional parameters that can be specified in the estimate_effect() method.
‘rd_variable_name’: name of the variable on which the discontinuity occurs. This is the instrument.
‘rd_threshold_value’: Threshold at which the discontinuity occurs.
‘rd_bandwidth’: Distance from the threshold within which confounders can be considered the same between treatment and control. Considered band is (threshold +- bandwidth)
Initializes an estimator with data and names of relevant variables.
More description.
- Parameters
data – data frame containing the data
identified_estimand – probability expression representing the target identified estimand to estimate.
treatment – name of the treatment variable
outcome – name of the outcome variable
control_value – Value of the treatment in the control group, for effect estimation. If treatment is multi-variate, this can be a list.
treatment_value – Value of the treatment in the treated group, for effect estimation. If treatment is multi-variate, this can be a list.
test_significance – whether to test significance
evaluate_effect_strength – (Experimental) whether to evaluate the strength of effect
confidence_intervals – (Experimental) Binary flag indicating whether confidence intervals should be computed.
target_units – (Experimental) The units for which the treatment effect should be estimated. This can be a string for common specifications of target units (namely, “ate”, “att” and “atc”). It can also be a lambda function that can be used as an index for the data (pandas DataFrame). Alternatively, it can be a new DataFrame that contains values of the effect_modifiers and effect will be estimated only for this new data.
effect_modifiers – variables on which to compute separate effects, or return a heterogeneous effect function. Not all methods support this currently.
params – (optional) additional method parameters
- Returns
an instance of the estimator class.