@@ -79,3 +79,47 @@ def test_invalid_fault_t_do(self):
79
79
estimation_model .df ["fault_t_do" ] = 0
80
80
with self .assertRaises (ValueError ):
81
81
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