|
2 | 2 | from causal_testing.testing.causal_test_outcome import ExactValue, SomeEffect, Positive, Negative
|
3 | 3 | from causal_testing.testing.causal_test_result import CausalTestResult, TestValue
|
4 | 4 | from causal_testing.testing.estimators import LinearRegressionEstimator
|
| 5 | +from causal_testing.testing.validation import CausalValidator |
5 | 6 |
|
6 | 7 |
|
7 | 8 | class TestCausalTestOutcome(unittest.TestCase):
|
@@ -176,3 +177,33 @@ def test_someEffect_fail(self):
|
176 | 177 | "ci_high": 0.2,
|
177 | 178 | },
|
178 | 179 | )
|
| 180 | + |
| 181 | + def test_positive_risk_ratio_e_value(self): |
| 182 | + test_value = TestValue("risk_ratio", 1.5) |
| 183 | + ctr = CausalTestResult( |
| 184 | + estimator=self.estimator, |
| 185 | + test_value=test_value, |
| 186 | + confidence_intervals=[1.2, 1.8], |
| 187 | + effect_modifier_configuration=None, |
| 188 | + ) |
| 189 | + |
| 190 | + cv = CausalValidator() |
| 191 | + e_value, e_confidence_intervals = cv.estimate_e_value(ctr.test_value.value, ctr.confidence_intervals) |
| 192 | + self.assertEqual(round(e_value, 4), 2.366) |
| 193 | + self.assertEqual(round(e_confidence_intervals[0], 4), 1.6899) |
| 194 | + self.assertEqual(e_confidence_intervals[1], 1) |
| 195 | + |
| 196 | + def test_negative_risk_ratio_e_value(self): |
| 197 | + test_value = TestValue("risk_ratio", 0.8) |
| 198 | + ctr = CausalTestResult( |
| 199 | + estimator=self.estimator, |
| 200 | + test_value=test_value, |
| 201 | + confidence_intervals=[0.2, 0.9], |
| 202 | + effect_modifier_configuration=None, |
| 203 | + ) |
| 204 | + |
| 205 | + cv = CausalValidator() |
| 206 | + e_value, e_confidence_intervals = cv.estimate_e_value(ctr.test_value.value, ctr.confidence_intervals) |
| 207 | + self.assertEqual(round(e_value, 4), 1.809) |
| 208 | + self.assertEqual(e_confidence_intervals[0], 1) |
| 209 | + self.assertEqual(round(e_confidence_intervals[1], 4), 1.4625) |
0 commit comments