File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -352,15 +352,15 @@ def estimate_coefficient(self) -> float:
352
352
model = self ._run_linear_regression ()
353
353
newline = "\n "
354
354
treatment = [self .treatment ]
355
- if str (self .df .dtypes [self .treatment ]) == "object" :
355
+ if self . treatment in self . df . dtypes and str (self .df .dtypes [self .treatment ]) == "object" :
356
356
design_info = dmatrix (self .formula .split ("~" )[1 ], self .df ).design_info
357
357
treatment = design_info .column_names [design_info .term_name_slices [self .treatment ]]
358
358
assert set (treatment ).issubset (
359
359
model .params .index .tolist ()
360
360
), f"{ treatment } not in\n { ' ' + str (model .params .index ).replace (newline , newline + ' ' )} "
361
361
unit_effect = model .params [treatment ] # Unit effect is the coefficient of the treatment
362
362
[ci_low , ci_high ] = self ._get_confidence_intervals (model , treatment )
363
- if str (self .df .dtypes [self .treatment ]) != "object" :
363
+ if self . treatment not in self . df . dtypes or str (self .df .dtypes [self .treatment ]) != "object" :
364
364
unit_effect = unit_effect [0 ]
365
365
ci_low = ci_low [0 ]
366
366
ci_high = ci_high [0 ]
You can’t perform that action at this time.
0 commit comments