示例#1
0
 def test_match_openepi_sampledata(self):
     oe_irr = -0.001055
     oe_ci = -0.003275, 0.001166
     df = ze.load_sample_data(False)
     ird = IncidenceRateDifference()
     ird.fit(df, exposure='art', outcome='dead', time='t')
     npt.assert_allclose(ird.incidence_rate_difference[1], oe_irr, atol=1e-5)
     rf = ird.results
     npt.assert_allclose(rf.loc[rf.index == '1'][['IRD_LCL', 'IRD_UCL']], [oe_ci], atol=1e-5)
示例#2
0
 def test_multiple_exposures(self):
     df = pd.DataFrame()
     df['exp'] = [1]*50 + [0]*50 + [2]*50
     df['dis'] = [1]*25 + [0]*25 + [1]*25 + [0]*25 + [1]*25 + [0]*25
     df['t'] = 2
     ird = IncidenceRateDifference()
     ird.fit(df, exposure='exp', outcome='dis', time='t')
     assert ird.results.shape[0] == 3
     assert list(ird.results.index) == ['Ref:0', '1', '2']
示例#3
0
def measures_check():
    # 7) Check measures plots
    data_set = load_sample_data(False)
    rr = RiskRatio()
    rr.fit(data_set, exposure='art', outcome='dead')
    rr.plot(fmt='*', ecolor='r', barsabove=True, markersize=25)
    plt.show()
    rd = RiskDifference()
    rd.fit(data_set, exposure='art', outcome='dead')
    rd.plot()
    plt.show()
    ord = OddsRatio()
    ord.fit(data_set, exposure='art', outcome='dead')
    ord.plot()
    plt.show()
    irr = IncidenceRateRatio()
    irr.fit(data_set, exposure='art', outcome='dead', time='t')
    irr.plot()
    plt.show()
    ird = IncidenceRateDifference()
    ird.fit(data_set, exposure='art', outcome='dead', time='t')
    ird.plot()
    plt.show()
示例#4
0
 def test_incidence_rate_difference_reference_equal_to_0(self, time_data):
     ird = IncidenceRateDifference()
     ird.fit(time_data, exposure='exp', outcome='dis', time='t')
     assert ird.incidence_rate_difference[0] == 0