statspai.dtr¶
dtr ¶
Dynamic Treatment Regimes (DTR).
Estimates optimal sequential treatment rules when treatments are assigned over multiple time periods.
Functions:
| Name | Description |
|---|---|
- **G-estimation** : Structural nested mean model for optimal DTR |
(Robins 1986, 2004). |
References
Robins, J. M. (2004). Optimal Structural Nested Models for Optimal Sequential Decisions. In Proceedings of the Second Seattle Symposium in Biostatistics, 189-326. [@robins2004optimal]
Murphy, S. A. (2003). Optimal Dynamic Treatment Regimes. JRSS-B, 65(2), 331-355. [@murphy2003optimal]
GEstimation ¶
G-estimation for dynamic treatment regimes via SNMM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
|
required |
y
|
str
|
|
required |
treatments
|
list of str
|
|
required |
covariates_by_stage
|
list of list of str
|
|
required |
propensity_covariates
|
list of list of str
|
|
None
|
alpha
|
float
|
|
0.05
|
n_bootstrap
|
int
|
|
500
|
random_state
|
int
|
|
42
|
Examples:
>>> import numpy as np
>>> import pandas as pd
>>> import statspai as sp
>>> rng = np.random.default_rng(0)
>>> n = 300
>>> x1 = rng.normal(size=n)
>>> x2 = rng.normal(size=n)
>>> x3 = rng.normal(size=n)
>>> a1 = rng.integers(0, 2, size=n)
>>> a2 = rng.integers(0, 2, size=n)
>>> y = 1.0 * a1 + 0.5 * a2 + x1 + 0.5 * x2 + rng.normal(size=n)
>>> df = pd.DataFrame({
... "outcome": y, "A1": a1, "A2": a2,
... "x1": x1, "x2": x2, "x3": x3,
... })
>>> est = sp.GEstimation(
... df, y="outcome",
... treatments=["A1", "A2"],
... covariates_by_stage=[["x1", "x2"], ["x1", "x2", "x3"]],
... n_bootstrap=50, random_state=0,
... )
>>> res = est.fit()
>>> res.model_info["n_stages"]
2