Skip to content

Commit 940f278

Browse files
committed
All tests pass
1 parent a809a00 commit 940f278

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

causal_testing/testing/estimators.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,6 @@ def estimate_control_treatment(self, adjustment_config: dict = None) -> tuple[pd
431431
model = self._run_linear_regression()
432432
self.model = model
433433

434-
435-
436434
x = pd.DataFrame(columns=self.df.columns)
437435
x[self.treatment] = [self.treatment_value, self.control_value]
438436
x["Intercept"] = 1#self.intercept
@@ -532,7 +530,6 @@ def _run_linear_regression(self) -> RegressionResultsWrapper:
532530
)
533531
# model = sm.OLS(outcome_col, treatment_and_adjustments_cols).fit()
534532
model = smf.ols(formula=self.formula, data=self.df).fit()
535-
print(model.summary())
536533
return model
537534

538535
def _get_confidence_intervals(self, model):

tests/json_front_tests/test_json_class.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ def test_argparse(self):
6767

6868
def test_setup_modelling_scenario(self):
6969
self.json_class.setup()
70-
print(type(self.json_class.modelling_scenario))
71-
print(self.json_class.modelling_scenario)
7270
self.assertIsInstance(self.json_class.modelling_scenario, Scenario)
7371

7472
def test_setup_causal_specification(self):

tests/testing_tests/test_causal_test_engine.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,9 @@ def test_execute_test_observational_linear_regression_estimator_squared_term(sel
218218
self.minimal_adjustment_set,
219219
"C",
220220
self.causal_test_engine.scenario_execution_data_df,
221+
formula=f"C ~ A + {'+'.join(self.minimal_adjustment_set)} + (D ** 2)"
221222
)
222-
estimation_model.add_squared_term_to_df("D")
223+
# estimation_model.add_squared_term_to_df("D")
223224
causal_test_result = self.causal_test_engine.execute_test(estimation_model, self.causal_test_case)
224225
self.assertAlmostEqual(round(causal_test_result.test_value.value, 1), 4, delta=1)
225226

tests/testing_tests/test_estimators.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,12 @@ def test_program_15_1A(self):
200200
"smokeyrs",
201201
}
202202
linear_regression_estimator = LinearRegressionEstimator("qsmk", 1, 0, covariates, "wt82_71", df,
203-
formula="""wt82_71 ~ qsmk +
204-
age + np.power(age, 2) +
205-
wt71 + np.power(wt71, 2) +
206-
smokeintensity + np.power(smokeintensity, 2) +
207-
smokeyrs + np.power(smokeyrs, 2) +
203+
formula=f"""wt82_71 ~ qsmk +
204+
{'+'.join(sorted(list(covariates)))} +
205+
np.power(age, 2) +
206+
np.power(wt71, 2) +
207+
np.power(smokeintensity, 2) +
208+
np.power(smokeyrs, 2) +
208209
(qsmk * smokeintensity)""")
209210
# terms_to_square = ["age", "wt71", "smokeintensity", "smokeyrs"]
210211
# terms_to_product = [("qsmk", "smokeintensity")]
@@ -215,7 +216,7 @@ def test_program_15_1A(self):
215216

216217
model = linear_regression_estimator._run_linear_regression()
217218
self.assertEqual(round(model.params["qsmk"], 1), 2.6)
218-
self.assertEqual(round(model.params["qsmk*smokeintensity"], 2), 0.05)
219+
self.assertEqual(round(model.params["qsmk:smokeintensity"], 2), 0.05)
219220

220221
def test_program_15_no_interaction(self):
221222
"""Test whether our linear regression implementation produces the same results as program 15.1 (p. 163, 184)

0 commit comments

Comments
 (0)