예제 #1
0
 def test_transport_iptw(self, df_iptw):
     ipsw = IPSW(df_iptw, exposure='A', outcome='Y', selection='S', generalize=False, weights='iptw')
     ipsw.regression_models('L + W + W_sq', print_results=False)
     ipsw.fit()
     npt.assert_allclose(ipsw.risk_difference, 0.047296, atol=1e-5)
     npt.assert_allclose(ipsw.risk_ratio, 1.1372, atol=1e-4)
예제 #2
0
 def test_generalize_unstabilized(self, df_r):
     ipsw = IPSW(df_r, exposure='A', outcome='Y', selection='S', stabilized=False)
     ipsw.regression_models('L + W_sq', print_results=False)
     ipsw.fit()
     npt.assert_allclose(ipsw.risk_difference, 0.046809, atol=1e-5)
     npt.assert_allclose(ipsw.risk_ratio, 1.13905, atol=1e-4)
예제 #3
0
 def test_transport_stabilized(self, df_r):
     ipsw = IPSW(df_r, exposure='A', outcome='Y', selection='S', stabilized=True, generalize=False)
     ipsw.regression_models('L + W_sq', print_results=False)
     ipsw.fit()
     npt.assert_allclose(ipsw.risk_difference, 0.034896, atol=1e-5)
     npt.assert_allclose(ipsw.risk_ratio, 1.097139, atol=1e-4)
예제 #4
0
 def test_stabilize_error(self, df_c):
     ipsw = IPSW(df_c, exposure='A', outcome='Y', selection='S', stabilized=False)
     with pytest.raises(ValueError):
         ipsw.regression_models('L + W_sq', model_numerator='W', print_results=False)