statspai.dose_response¶
dose_response ¶
Continuous Treatment Effects: Dose-Response Estimation.
Estimates the dose-response function E[Y(t)] for continuous treatments using the generalized propensity score (GPS) approach and kernel-based methods.
References
Hirano, K. & Imbens, G. W. (2004). The Propensity Score with Continuous Treatments. Applied Bayesian Modeling and Causal Inference from Incomplete-Data Perspectives, 226164, 73-84. [@hirano2004propensity]
Kennedy, E. H., Ma, Z., McHugh, M. D., & Small, D. S. (2017). Non-parametric methods for doubly robust estimation of continuous treatment effects. JRSS-B, 79(4), 1229-1245. [@kennedy2017parametric]
DoseResponse ¶
Generalized Propensity Score dose-response estimator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
|
required |
y
|
str
|
|
required |
treat
|
str
|
|
required |
covariates
|
list of str
|
|
required |
n_dose_points
|
int
|
|
20
|
dose_range
|
tuple
|
|
None
|
treatment_model
|
sklearn estimator
|
|
None
|
outcome_model
|
sklearn estimator
|
|
None
|
n_bootstrap
|
int
|
|
200
|
alpha
|
float
|
|
0.05
|
random_state
|
int
|
|
42
|
dose_response ¶
dose_response(data: DataFrame, y: str, treat: str, covariates: List[str], n_dose_points: int = 20, dose_range: Optional[Tuple[float, float]] = None, treatment_model: Optional[BaseEstimator] = None, outcome_model: Optional[BaseEstimator] = None, n_bootstrap: int = 200, alpha: float = 0.05, random_state: int = 42) -> CausalResult
Estimate the dose-response function for a continuous treatment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
Input data. |
required |
y
|
str
|
Outcome variable. |
required |
treat
|
str
|
Continuous treatment variable. |
required |
covariates
|
list of str
|
Covariate names. |
required |
n_dose_points
|
int
|
Number of dose levels to evaluate. |
20
|
dose_range
|
tuple of (float, float)
|
(min, max) dose range. If None, uses 5th-95th percentile. |
None
|
treatment_model
|
sklearn estimator
|
Model for E[T|X]. Default: GBM. |
None
|
outcome_model
|
sklearn estimator
|
Model for E[Y|T, GPS]. Default: GBM. |
None
|
n_bootstrap
|
int
|
Bootstrap iterations for confidence bands. |
200
|
alpha
|
float
|
Significance level. |
0.05
|
random_state
|
int
|
|
42
|
Returns:
| Type | Description |
|---|---|
CausalResult
|
detail contains the dose-response curve: columns 'dose', 'response', 'se', 'ci_lower', 'ci_upper'. model_info contains 'avg_marginal_effect' (derivative). |
Examples:
scigan ¶
scigan(data: DataFrame, y: str, treatment: str, covariates: Sequence[str], t_grid: Optional[Sequence[float]] = None, propensity_weights: Optional[ndarray] = None, **kwargs) -> VCNetResult
Adversarial dose-response estimator (Bica et al. 2020).
The reference SCIGAN architecture is a GAN — too heavy to ship as
a dependency-free algorithm. This entry point exposes a
propensity-weighted VCNet fit that captures the essential
"balancing" behaviour of SCIGAN: residual imbalance along the
treatment axis is re-weighted using a user-provided propensity_weights
(g(T | X)^{-1}). For the full SCIGAN training loop, plug in
your own GAN-generated counterfactual samples and pass the
re-weighting through propensity_weights.