File tree Expand file tree Collapse file tree 3 files changed +27
-4
lines changed Expand file tree Collapse file tree 3 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -747,7 +747,7 @@ def __init__(
747
747
def _input_validation (self ):
748
748
"""Validate the input data and model formula for correctness"""
749
749
if not _series_has_2_levels (self .data [self .group_variable_name ]):
750
- raise ValueError (
750
+ raise DataException (
751
751
f"""
752
752
There must be 2 levels of the grouping variable
753
753
{ self .group_variable_name } . I.e. the treated and untreated.
Original file line number Diff line number Diff line change @@ -141,3 +141,26 @@ def test_sc_brexit_input_error():
141
141
formula = formula ,
142
142
model = cp .pymc_models .WeightedSumFitter (sample_kwargs = sample_kwargs ),
143
143
)
144
+
145
+
146
+ # Pre-post NEGD
147
+
148
+
149
+ def test_ancova_validation_2_levels ():
150
+ """Test that we get a DataException group variable is not dummy coded"""
151
+ df = pd .DataFrame (
152
+ {
153
+ "group" : [0 , 0 , 1 , 2 ],
154
+ "pre" : [1 , 1 , 3 , 4 ],
155
+ "post" : [1 , 2 , 3 , 4 ],
156
+ }
157
+ )
158
+
159
+ with pytest .raises (DataException ):
160
+ _ = cp .pymc_experiments .PrePostNEGD (
161
+ df ,
162
+ formula = "post ~ 1 + C(group) + pre" ,
163
+ group_variable_name = "group" ,
164
+ pretreatment_variable_name = "pre" ,
165
+ model = cp .pymc_models .LinearRegression (sample_kwargs = sample_kwargs ),
166
+ )
You can’t perform that action at this time.
0 commit comments