Example #1
0
 def test_no_model_error(self, df_c):
     gtf = GTransportFormula(df_c,
                             exposure='A',
                             outcome='Y',
                             selection='S',
                             generalize=True)
     with pytest.raises(ValueError):
         gtf.fit()
Example #2
0
 def test_transport_conf(self, df_c):
     gtf = GTransportFormula(df_c,
                             exposure='A',
                             outcome='Y',
                             selection='S',
                             generalize=False)
     gtf.outcome_model('A + L + L:A + W_sq + W_sq:A + W_sq:A:L',
                       print_results=False)
     gtf.fit()
     npt.assert_allclose(gtf.risk_difference, 0.042574, atol=1e-5)
     npt.assert_allclose(gtf.risk_ratio, 1.124257, atol=1e-4)
Example #3
0
 def test_generalize(self, df_r):
     gtf = GTransportFormula(df_r,
                             exposure='A',
                             outcome='Y',
                             selection='S',
                             generalize=True)
     gtf.outcome_model('A + L + L:A + W_sq + W_sq:A + W_sq:A:L',
                       print_results=False)
     gtf.fit()
     npt.assert_allclose(gtf.risk_difference, 0.064038, atol=1e-5)
     npt.assert_allclose(gtf.risk_ratio, 1.203057, atol=1e-4)
Example #4
0
 def test_generalize_weight(self, df_c):
     gtf = GTransportFormula(df_c,
                             exposure='A',
                             outcome='Y',
                             selection='S',
                             generalize=True,
                             weights='weight')
     gtf.outcome_model('A + L + L:A + W_sq + W_sq:A + W_sq:A:L',
                       print_results=False)
     gtf.fit()
     npt.assert_allclose(gtf.risk_difference, 0.048949, atol=1e-5)
     npt.assert_allclose(gtf.risk_ratio, 1.149556, atol=1e-4)