Estimators
IPW
IPW(effect_type='ATE', treatment_col='treatment', outcome_col='outcome', ps_col='ps', clip_percentile: float = 1, eps: float = 1e-09)
Bases: BaseEstimator
Inverse Probability Weighting estimator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
effect_type
|
Type of causal effect to estimate |
'ATE'
|
|
treatment_col
|
Name of treatment column |
'treatment'
|
|
outcome_col
|
Name of outcome column |
'outcome'
|
|
ps_col
|
Name of propensity score column |
'ps'
|
|
clip_percentile
|
float
|
percentile to clip the weights at |
1
|
eps
|
float
|
Small constant for numerical stability in denominators |
1e-09
|
Source code in CausalEstimate/estimators/ipw.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
AIPW
AIPW(effect_type: str = 'ATE', treatment_col: str = 'treatment', outcome_col: str = 'outcome', ps_col: str = 'ps', probas_t1_col: str = 'probas_t1', probas_t0_col: str = 'probas_t0', clip_percentile: float = 1, eps: float = 1e-09)
Bases: BaseEstimator
Augmented Inverse Probability Weighting (AIPW) estimator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
effect_type
|
str
|
Type of causal effect to estimate |
'ATE'
|
treatment_col
|
str
|
Name of treatment column |
'treatment'
|
outcome_col
|
str
|
Name of outcome column |
'outcome'
|
ps_col
|
str
|
Name of propensity score column |
'ps'
|
probas_t1_col
|
str
|
Name of predicted probabilities under treatment column |
'probas_t1'
|
probas_t0_col
|
str
|
Name of predicted probabilities under control column |
'probas_t0'
|
clip_percentile
|
float
|
Upper percentile for clipping, in (0, 1]. Default 1 (no clipping). |
1
|
eps
|
float
|
Small constant for numerical stability in denominators |
1e-09
|
Source code in CausalEstimate/estimators/aipw.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
TMLE
TMLE(effect_type: str = 'ATE', treatment_col: str = 'treatment', outcome_col: str = 'outcome', ps_col: str = 'ps', probas_col: str = 'probas', probas_t1_col: str = 'probas_t1', probas_t0_col: str = 'probas_t0', clip_percentile: float = 1, eps: float = 1e-09, y_bounds: Optional[Tuple[float, float]] = None)
Bases: BaseEstimator
Targeted Maximum Likelihood Estimation (TMLE) estimator.
Binary outcomes use the logistic fluctuation directly. A continuous
outcome (ATE/ATT only) is rescaled to [0, 1] with y_bounds
(default: observed min/max of the outcome), targeted on that scale,
and the results are mapped back (Gruber & van der Laan, 2010).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
effect_type
|
str
|
Type of causal effect to estimate |
'ATE'
|
treatment_col
|
str
|
Name of treatment column |
'treatment'
|
outcome_col
|
str
|
Name of outcome column |
'outcome'
|
ps_col
|
str
|
Name of propensity score column |
'ps'
|
probas_col
|
str
|
Name of predicted probabilities column |
'probas'
|
probas_t1_col
|
str
|
Name of predicted probabilities under treatment column |
'probas_t1'
|
probas_t0_col
|
str
|
Name of predicted probabilities under control column |
'probas_t0'
|
clip_percentile
|
float
|
Upper percentile for clipping, in (0, 1]. Default 1 (no clipping). |
1
|
eps
|
float
|
Small constant for numerical stability in denominators |
1e-09
|
y_bounds
|
Optional[Tuple[float, float]]
|
(min, max) of a continuous outcome. Predictions are clipped to these bounds. Passing it forces the continuous path even for a 0/1 outcome; RR/RRT/ARR ignore it. |
None
|
Source code in CausalEstimate/estimators/tmle.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
Matching
Matching(effect_type: str = 'ATE', treatment_col: str = TREATMENT_COL, outcome_col: str = OUTCOME_COL, ps_col: str = PS_COL, match_optimal: bool = True, n_controls: int = 1, caliper: float = None, strict: bool = True)
Bases: BaseEstimator
Propensity Score Matching estimator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
effect_type
|
str
|
Type of causal effect to estimate |
'ATE'
|
treatment_col
|
str
|
Name of treatment column |
TREATMENT_COL
|
outcome_col
|
str
|
Name of outcome column |
OUTCOME_COL
|
ps_col
|
str
|
Name of propensity score column |
PS_COL
|
match_optimal
|
bool
|
Whether to use optimal matching (True) or greedy matching (False) |
True
|
n_controls
|
int
|
Number of controls to match for each treated individual |
1
|
caliper
|
float
|
Maximum allowable distance (propensity score difference) for matching |
None
|
strict
|
bool
|
If True (and using greedy matching), raise error if any treated subject cannot be matched. If False, skip unmatched subjects. |
True
|
Source code in CausalEstimate/estimators/matching.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
MultiEstimator
MultiEstimator(estimators: List[BaseEstimator], verbose: bool = False)
estimators is a list of estimator instances (AIPW, TMLE, IPW, etc.).
Each is already configured with its own column names and effect_type.
Source code in CausalEstimate/core/multi_estimator.py
25 26 27 28 29 30 31 | |
compute_effects
compute_effects(df: DataFrame, n_bootstraps: int = 1, apply_common_support: bool = False, common_support_threshold: float = 0.05, return_bootstrap_samples: bool = False) -> Dict[str, Dict]
Loops over self.estimators, applies optional common support and bootstrap, and returns a dictionary with each estimator's results.
When bootstrapping is enabled (n_bootstraps > 1), each estimator's output will include: - effect: the mean effect across bootstrap samples - std_err: the standard deviation of the bootstrap effects - CI95_lower and CI95_upper: the 95% confidence interval (using the percentile method) - Optionally, raw bootstrap estimates under 'bootstrap_samples' if return_bootstrap_samples is True.
Source code in CausalEstimate/core/multi_estimator.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |