Skip to content

Commit 1d4afee

Browse files
committed
codecov
1 parent ddc3c60 commit 1d4afee

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/estimation_tests/test_ipcw_estimator.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,47 @@ def test_invalid_fault_t_do(self):
7979
estimation_model.df["fault_t_do"] = 0
8080
with self.assertRaises(ValueError):
8181
estimate, intervals = estimation_model.estimate_hazard_ratio()
82+
83+
def test_no_individual_began_control_strategy(self):
84+
timesteps_per_intervention = 1
85+
control_strategy = [[t, "t", 0] for t in range(1, 4, timesteps_per_intervention)]
86+
treatment_strategy = [[t, "t", 1] for t in range(1, 4, timesteps_per_intervention)]
87+
outcome = "outcome"
88+
fit_bl_switch_formula = "xo_t_do ~ time"
89+
df = pd.read_csv("tests/resources/data/temporal_data.csv")
90+
df["t"] = 1
91+
df["ok"] = df["outcome"] == 1
92+
with self.assertRaises(ValueError):
93+
estimation_model = IPCWEstimator(
94+
df,
95+
timesteps_per_intervention,
96+
control_strategy,
97+
treatment_strategy,
98+
outcome,
99+
"ok",
100+
fit_bl_switch_formula=fit_bl_switch_formula,
101+
fit_bltd_switch_formula=fit_bl_switch_formula,
102+
eligibility=None,
103+
)
104+
105+
def test_no_individual_began_treatment_strategy(self):
106+
timesteps_per_intervention = 1
107+
control_strategy = [[t, "t", 0] for t in range(1, 4, timesteps_per_intervention)]
108+
treatment_strategy = [[t, "t", 1] for t in range(1, 4, timesteps_per_intervention)]
109+
outcome = "outcome"
110+
fit_bl_switch_formula = "xo_t_do ~ time"
111+
df = pd.read_csv("tests/resources/data/temporal_data.csv")
112+
df["t"] = 0
113+
df["ok"] = df["outcome"] == 1
114+
with self.assertRaises(ValueError):
115+
estimation_model = IPCWEstimator(
116+
df,
117+
timesteps_per_intervention,
118+
control_strategy,
119+
treatment_strategy,
120+
outcome,
121+
"ok",
122+
fit_bl_switch_formula=fit_bl_switch_formula,
123+
fit_bltd_switch_formula=fit_bl_switch_formula,
124+
eligibility=None,
125+
)

0 commit comments

Comments
 (0)