|
3 | 3 | import logging
|
4 | 4 | from abc import ABC, abstractmethod
|
5 | 5 | from typing import Any
|
| 6 | +from math import ceil |
6 | 7 |
|
7 | 8 | import numpy as np
|
8 | 9 | import pandas as pd
|
|
16 | 17 | from statsmodels.tools.sm_exceptions import PerfectSeparationError
|
17 | 18 |
|
18 | 19 | from causal_testing.specification.variable import Variable
|
19 |
| -from math import ceil |
20 | 20 |
|
21 | 21 | logger = logging.getLogger(__name__)
|
22 | 22 |
|
@@ -116,7 +116,6 @@ def __init__(
|
116 | 116 | effect_modifiers = []
|
117 | 117 |
|
118 | 118 | if formula is not None:
|
119 |
| - # TODO: validate it |
120 | 119 | self.formula = formula
|
121 | 120 | else:
|
122 | 121 | terms = [treatment] + sorted(list(adjustment_set)) + sorted(list(effect_modifiers))
|
@@ -158,13 +157,11 @@ def _run_logistic_regression(self, data) -> RegressionResultsWrapper:
|
158 | 157 | cols = [self.treatment]
|
159 | 158 | cols += [x for x in self.adjustment_set if x not in cols]
|
160 | 159 | treatment_and_adjustments_cols = reduced_df[cols + ["Intercept"]]
|
161 |
| - outcome_col = reduced_df[[self.outcome]] |
162 | 160 | for col in treatment_and_adjustments_cols:
|
163 | 161 | if str(treatment_and_adjustments_cols.dtypes[col]) == "object":
|
164 | 162 | treatment_and_adjustments_cols = pd.get_dummies(
|
165 | 163 | treatment_and_adjustments_cols, columns=[col], drop_first=True
|
166 | 164 | )
|
167 |
| - # regression = sm.Logit(outcome_col, treatment_and_adjustments_cols) # This one works |
168 | 165 | model = smf.logit(formula=self.formula, data=data).fit(disp=0)
|
169 | 166 | return model
|
170 | 167 |
|
@@ -322,7 +319,6 @@ def __init__(
|
322 | 319 | effect_modifiers = []
|
323 | 320 |
|
324 | 321 | if formula is not None:
|
325 |
| - # TODO: validate it |
326 | 322 | self.formula = formula
|
327 | 323 | else:
|
328 | 324 | terms = [treatment] + sorted(list(adjustment_set)) + sorted(list(effect_modifiers))
|
@@ -485,13 +481,11 @@ def _run_linear_regression(self) -> RegressionResultsWrapper:
|
485 | 481 | cols = [self.treatment]
|
486 | 482 | cols += [x for x in self.adjustment_set if x not in cols]
|
487 | 483 | treatment_and_adjustments_cols = reduced_df[cols + ["Intercept"]]
|
488 |
| - outcome_col = reduced_df[[self.outcome]] |
489 | 484 | for col in treatment_and_adjustments_cols:
|
490 | 485 | if str(treatment_and_adjustments_cols.dtypes[col]) == "object":
|
491 | 486 | treatment_and_adjustments_cols = pd.get_dummies(
|
492 | 487 | treatment_and_adjustments_cols, columns=[col], drop_first=True
|
493 | 488 | )
|
494 |
| - # model = sm.OLS(outcome_col, treatment_and_adjustments_cols).fit() |
495 | 489 | model = smf.ols(formula=self.formula, data=self.df).fit()
|
496 | 490 | return model
|
497 | 491 |
|
|
0 commit comments