@@ -166,15 +166,15 @@ def test_estimate_coefficient(self):
166
166
Test we get the correct coefficient.
167
167
"""
168
168
iv_estimator = InstrumentalVariableEstimator (
169
+ df = self .df ,
169
170
treatment = "X" ,
170
171
treatment_value = None ,
171
172
control_value = None ,
172
173
adjustment_set = set (),
173
174
outcome = "Y" ,
174
175
instrument = "Z" ,
175
- df = self .df ,
176
176
)
177
- self .assertEqual (iv_estimator .estimate_coefficient (), 2 )
177
+ self .assertEqual (iv_estimator .estimate_coefficient (self . df ), 2 )
178
178
179
179
180
180
class TestLinearRegressionEstimator (unittest .TestCase ):
@@ -192,21 +192,21 @@ def setUpClass(cls) -> None:
192
192
def test_program_11_2 (self ):
193
193
"""Test whether our linear regression implementation produces the same results as program 11.2 (p. 141)."""
194
194
df = self .chapter_11_df
195
- linear_regression_estimator = LinearRegressionEstimator ("treatments" , 100 , 90 , set (), "outcomes" , df )
195
+ linear_regression_estimator = LinearRegressionEstimator ("treatments" , None , None , set (), "outcomes" , df )
196
196
model = linear_regression_estimator ._run_linear_regression ()
197
197
ate , _ = linear_regression_estimator .estimate_unit_ate ()
198
198
199
199
print (model .summary ())
200
200
self .assertEqual (round (model .params ["Intercept" ] + 90 * model .params ["treatments" ], 1 ), 216.9 )
201
201
202
202
# Increasing treatments from 90 to 100 should be the same as 10 times the unit ATE
203
- self .assertEqual (round (10 * model .params ["treatments" ], 1 ), round (ate , 1 ))
203
+ self .assertEqual (round (model .params ["treatments" ], 1 ), round (ate , 1 ))
204
204
205
205
def test_program_11_3 (self ):
206
206
"""Test whether our linear regression implementation produces the same results as program 11.3 (p. 144)."""
207
207
df = self .chapter_11_df .copy ()
208
208
linear_regression_estimator = LinearRegressionEstimator (
209
- "treatments" , 100 , 90 , set (), "outcomes" , df , formula = "outcomes ~ treatments + np.power(treatments, 2)"
209
+ "treatments" , None , None , set (), "outcomes" , df , formula = "outcomes ~ treatments + np.power(treatments, 2)"
210
210
)
211
211
model = linear_regression_estimator ._run_linear_regression ()
212
212
ate , _ = linear_regression_estimator .estimate_unit_ate ()
@@ -220,7 +220,7 @@ def test_program_11_3(self):
220
220
197.1 ,
221
221
)
222
222
# Increasing treatments from 90 to 100 should be the same as 10 times the unit ATE
223
- self .assertEqual (round (10 * model .params ["treatments" ], 3 ), round (ate , 3 ))
223
+ self .assertEqual (round (model .params ["treatments" ], 3 ), round (ate , 3 ))
224
224
225
225
def test_program_15_1A (self ):
226
226
"""Test whether our linear regression implementation produces the same results as program 15.1 (p. 163, 184)."""
0 commit comments