def test_transport(self, df_r):
     aipw = AIPSW(df_r, exposure='A', outcome='Y', selection='S', generalize=False)
     aipw.weight_model('L + W_sq', print_results=False)
     aipw.outcome_model('A + L + L:A + W_sq + W_sq:A + W_sq:A:L', print_results=False)
     aipw.fit()
     npt.assert_allclose(aipw.risk_difference, 0.05479, atol=1e-5)
     npt.assert_allclose(aipw.risk_ratio, 1.16352, atol=1e-4)
 def test_transport_conf(self, df_iptw):
     aipw = AIPSW(df_iptw, exposure='A', outcome='Y', selection='S', generalize=False, weights='iptw')
     aipw.weight_model('L + W_sq', print_results=False)
     aipw.outcome_model('A + L + L:A + W_sq + W_sq:A + W_sq:A:L', print_results=False)
     aipw.fit()
     npt.assert_allclose(aipw.risk_difference, 0.041407, atol=1e-5)
     npt.assert_allclose(aipw.risk_ratio, 1.120556, atol=1e-4)
    def test_no_model_error(self, df_c):
        aipw = AIPSW(df_c, exposure='A', outcome='Y', selection='S', generalize=True)
        with pytest.raises(ValueError):
            aipw.fit()

        aipw.weight_model('L', print_results=False)
        with pytest.raises(ValueError):
            aipw.fit()

        aipw = AIPSW(df_c, exposure='A', outcome='Y', selection='S', generalize=True)
        aipw.outcome_model('A + L')
        with pytest.raises(ValueError):
            aipw.fit()