statspai.multi_treatment¶
multi_treatment ¶
Multi-valued Treatment Effects.
Estimates causal effects when the treatment takes more than two values (e.g., different drug dosages, multiple policy options).
Uses inverse probability weighting with multinomial propensity scores.
References
Cattaneo, M. D. (2010). Efficient semiparametric estimation of multi-valued treatment effects. Journal of Econometrics, 155(2), 138-154. [@cattaneo2010efficient]
Lechner, M. (2001). Identification and estimation of causal effects of multiple treatments under the conditional independence assumption. Econometric Evaluation of Labour Market Policies, 43-58. [@lechner2001identification]
MultiTreatment ¶
Multi-valued treatment effects estimator.
Estimates AIPW (doubly robust) contrasts of each treatment arm
against a reference level for a discrete treatment D in
{0, 1, ..., K}. Construct, then call :meth:fit.
Examples:
>>> import numpy as np
>>> import pandas as pd
>>> import statspai as sp
>>> from statspai.multi_treatment.multi_ipw import MultiTreatment
>>> rng = np.random.default_rng(0)
>>> n = 120
>>> age = rng.normal(50, 10, n)
>>> weight = rng.normal(70, 12, n)
>>> dose = rng.integers(0, 3, n)
>>> y = 2.0 * dose + 0.05 * age + rng.normal(0, 1, n)
>>> df = pd.DataFrame({'outcome': y, 'dose_level': dose,
... 'age': age, 'weight': weight})
>>> est = MultiTreatment(data=df, y='outcome', treat='dose_level',
... covariates=['age', 'weight'], n_bootstrap=15)
>>> res = est.fit()
>>> list(res.detail['treatment'])
[1, 2]
References
[@cattaneo2010efficient]
multi_treatment ¶
multi_treatment(data: DataFrame, y: str, treat: str, covariates: List[str], reference: Optional[int] = None, n_bootstrap: int = 500, alpha: float = 0.05, random_state: int = 42) -> CausalResult
Estimate effects of multi-valued treatments via AIPW.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
Input data. |
required |
y
|
str
|
Outcome variable. |
required |
treat
|
str
|
Treatment variable with K+1 levels (0, 1, ..., K). |
required |
covariates
|
list of str
|
Covariate names. |
required |
reference
|
int
|
Reference treatment level (control). Default: minimum value. |
None
|
n_bootstrap
|
int
|
|
500
|
alpha
|
float
|
|
0.05
|
random_state
|
int
|
|
42
|
Returns:
| Type | Description |
|---|---|
CausalResult
|
detail DataFrame has pairwise effects vs reference. model_info contains all pairwise contrasts. |
Examples:
>>> import numpy as np
>>> import pandas as pd
>>> import statspai as sp
>>> rng = np.random.default_rng(0)
>>> n = 120
>>> age = rng.normal(50, 10, n)
>>> weight = rng.normal(70, 12, n)
>>> # Treatment with 3 levels: 0 (control), 1 (low), 2 (high)
>>> dose = rng.integers(0, 3, n)
>>> y = 2.0 * dose + 0.05 * age + rng.normal(0, 1, n)
>>> df = pd.DataFrame({'outcome': y, 'dose_level': dose,
... 'age': age, 'weight': weight})
>>> result = sp.multi_treatment(df, y='outcome', treat='dose_level',
... covariates=['age', 'weight'],
... n_bootstrap=15)
>>> list(result.detail['treatment']) # effects vs control
[1, 2]