def test_match_sas_ci(self, data_set): sas_ci = 0.6757, 1.4799 rr = RiskRatio() rr.fit(data_set, exposure='exp', outcome='dis') df = rr.results npt.assert_allclose( np.round(df.loc[df.index == '1'][['RR_LCL', 'RR_UCL']], 4), [sas_ci])
def test_match_sas_sampledata(self): sas_rd = 0.742118331 sas_se = 0.312612740 sas_ci = 0.402139480, 1.369523870 df = ze.load_sample_data(False) rr = RiskRatio() rr.fit(df, exposure='art', outcome='dead') npt.assert_allclose(rr.risk_ratio[1], sas_rd, rtol=1e-5) rf = rr.results npt.assert_allclose(rf.loc[rf.index == '1'][['RR_LCL', 'RR_UCL']], [sas_ci], rtol=1e-5) npt.assert_allclose(rf.loc[rf.index == '1'][['SD(RR)']], sas_se, rtol=1e-5)
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()
def test_multiple_exposures(self, multi_exposures): rr = RiskRatio() rr.fit(multi_exposures, exposure='exp', outcome='dis') assert rr.results.shape[0] == 3 assert list(rr.results.index) == ['Ref:0', '1', '2']
def test_risk_ratio_equal_to_1(self, data_set): rr = RiskRatio() rr.fit(data_set, exposure='exp', outcome='dis') assert rr.risk_ratio[1] == 1