コード例 #1
0
ファイル: test_tost.py プロジェクト: rogerlew/statsmodels
def test_tost_asym():
    x1, x2 = clinic[:15, 2], clinic[15:, 2]
    #Note: x1, x2 reversed by definition in multeq.dif
    assert_almost_equal(x2.mean() - x1.mean(), tost_clinic_1_asym.estimate, 13)
    resa = smws.tost_ind(x2, x1, -1.5, 0.6, usevar='separate')
    assert_almost_equal(resa[0], tost_clinic_1_asym.p_value, 13)

    #multi-endpoints, asymmetric bounds, vectorized
    resall = smws.tost_ind(clinic[15:, 2:7],
                           clinic[:15, 2:7], [-1.0, -1.0, -1.5, -1.5, -1.5],
                           0.6,
                           usevar='separate')
    assert_almost_equal(resall[0], tost_clinic_all_no_multi.p_value, 13)

    #SMOKE tests: foe multi-endpoint vectorized, k on k
    resall = smws.tost_ind(clinic[15:, 2:7],
                           clinic[:15, 2:7], [-1.0, -1.0, -1.5, -1.5, -1.5],
                           0.6,
                           usevar='separate',
                           transform=np.log)
    resall = smws.tost_ind(clinic[15:, 2:7],
                           clinic[:15, 2:7], [-1.0, -1.0, -1.5, -1.5, -1.5],
                           0.6,
                           usevar='separate',
                           transform=np.exp)

    resall = smws.tost_paired(clinic[15:, 2:7],
                              clinic[:15, 2:7], [-1.0, -1.0, -1.5, -1.5, -1.5],
                              0.6,
                              transform=np.log)
    resall = smws.tost_paired(clinic[15:, 2:7],
                              clinic[:15, 2:7], [-1.0, -1.0, -1.5, -1.5, -1.5],
                              0.6,
                              transform=np.exp)

    resall = smws.ttest_ind(clinic[15:, 2:7],
                            clinic[:15, 2:7],
                            value=[-1.0, -1.0, -1.5, -1.5, -1.5])

    #k on 1: compare all with reference
    resall = smws.tost_ind(clinic[15:, 2:7],
                           clinic[:15, 2:3], [-1.0, -1.0, -1.5, -1.5, -1.5],
                           0.6,
                           usevar='separate')
    resa3_2 = smws.tost_ind(clinic[15:, 3:4],
                            clinic[:15, 2:3], [-1.0, -1.0, -1.5, -1.5, -1.5],
                            0.6,
                            usevar='separate')
    assert_almost_equal(resall[0][1], resa3_2[0][1], decimal=13)
    resall = smws.tost_ind(clinic[15:, 2],
                           clinic[:15, 2], [-1.0, -0.5, -0.7, -1.5, -1.5],
                           0.6,
                           usevar='separate')
    resall = smws.tost_ind(clinic[15:, 2],
                           clinic[:15, 2], [-1.0, -0.5, -0.7, -1.5, -1.5],
                           np.repeat(0.6, 5),
                           usevar='separate')
コード例 #2
0
ファイル: test_tost.py プロジェクト: QuocTran/statsmodels
def test_tost_log():
    x1, x2 = clinic[:15, 2], clinic[15:, 2]

    resp = smws.tost_paired(x1, x2, 0.8, 1.25, transform=np.log)
    assert_almost_equal(resp[0], tost_clinic_1_paired.p_value, 13)

    resi = smws.tost_ind(x1, x2, 0.8, 1.25, transform=np.log, usevar='separate')
    assert_almost_equal(resi[0], tost_clinic_1_indep.p_value, 13)
コード例 #3
0
ファイル: test_tost.py プロジェクト: QuocTran/statsmodels
def test_tost_asym():
    x1, x2 = clinic[:15, 2], clinic[15:, 2]
    #Note: x1, x2 reversed by definition in multeq.dif
    assert_almost_equal(x2.mean() - x1.mean(), tost_clinic_1_asym.estimate, 13)
    resa = smws.tost_ind(x2, x1, -1.5, 0.6, usevar='separate')
    assert_almost_equal(resa[0], tost_clinic_1_asym.p_value, 13)

    #multi-endpoints, asymmetric bounds, vectorized
    resall = smws.tost_ind(clinic[15:, 2:7], clinic[:15, 2:7],
                           [-1.0, -1.0, -1.5, -1.5, -1.5], 0.6,
                           usevar='separate')
    assert_almost_equal(resall[0], tost_clinic_all_no_multi.p_value, 13)

    #SMOKE tests: foe multi-endpoint vectorized, k on k
    resall = smws.tost_ind(clinic[15:, 2:7], clinic[:15, 2:7],
                           [-1.0, -1.0, -1.5, -1.5, -1.5], 0.6,
                           usevar='separate', transform=np.log)
    resall = smws.tost_ind(clinic[15:, 2:7], clinic[:15, 2:7],
                           [-1.0, -1.0, -1.5, -1.5, -1.5], 0.6,
                           usevar='separate', transform=np.exp)

    resall = smws.tost_paired(clinic[15:, 2:7], clinic[:15, 2:7],
                              [-1.0, -1.0, -1.5, -1.5, -1.5], 0.6,
                              transform=np.log)
    resall = smws.tost_paired(clinic[15:, 2:7], clinic[:15, 2:7],
                              [-1.0, -1.0, -1.5, -1.5, -1.5], 0.6,
                              transform=np.exp)

    resall = smws.ttest_ind(clinic[15:, 2:7], clinic[:15, 2:7],
                              value=[-1.0, -1.0, -1.5, -1.5, -1.5])

    #k on 1: compare all with reference
    resall = smws.tost_ind(clinic[15:, 2:7], clinic[:15, 2:3],
                           [-1.0, -1.0, -1.5, -1.5, -1.5], 0.6, usevar='separate')
    resa3_2 = smws.tost_ind(clinic[15:, 3:4], clinic[:15, 2:3],
                           [-1.0, -1.0, -1.5, -1.5, -1.5], 0.6, usevar='separate')
    assert_almost_equal(resall[0][1], resa3_2[0][1], decimal=13)
    resall = smws.tost_ind(clinic[15:, 2], clinic[:15, 2],
                           [-1.0, -0.5, -0.7, -1.5, -1.5], 0.6, usevar='separate')
    resall = smws.tost_ind(clinic[15:, 2], clinic[:15, 2],
                           [-1.0, -0.5, -0.7, -1.5, -1.5],
                           np.repeat(0.6,5), usevar='separate')
コード例 #4
0
ファイル: test_tost.py プロジェクト: rogerlew/statsmodels
def test_tost_log():
    x1, x2 = clinic[:15, 2], clinic[15:, 2]

    resp = smws.tost_paired(x1, x2, 0.8, 1.25, transform=np.log)
    assert_almost_equal(resp[0], tost_clinic_1_paired.p_value, 13)

    resi = smws.tost_ind(x1,
                         x2,
                         0.8,
                         1.25,
                         transform=np.log,
                         usevar='separate')
    assert_almost_equal(resi[0], tost_clinic_1_indep.p_value, 13)
コード例 #5
0
ファイル: test_tost.py プロジェクト: QuocTran/statsmodels
def tost_transform_paired():
    raw = np.array('''\
       103.4 90.11  59.92 77.71  68.17 77.71  94.54 97.51
       69.48 58.21  72.17 101.3  74.37 79.84  84.44 96.06
       96.74 89.30  94.26 97.22  48.52 61.62  95.68 85.80'''.split(), float)

    x, y = raw.reshape(-1,2).T

    res1 = smws.tost_paired(x, y, 0.8, 1.25, transform=np.log)
    res_sas = (0.0031, (3.38, 0.0031), (-5.90, 0.00005))
    assert_almost_equal(res1[0], res_sas[0], 3)
    assert_almost_equal(res1[1:], res_sas[1:], 2)
    #result R tost
    assert_almost_equal(res1[0], tost_s_paired.p_value, 13)
コード例 #6
0
ファイル: test_tost.py プロジェクト: rogerlew/statsmodels
def tost_transform_paired():
    raw = np.array(
        '''\
       103.4 90.11  59.92 77.71  68.17 77.71  94.54 97.51
       69.48 58.21  72.17 101.3  74.37 79.84  84.44 96.06
       96.74 89.30  94.26 97.22  48.52 61.62  95.68 85.80'''.split(), float)

    x, y = raw.reshape(-1, 2).T

    res1 = smws.tost_paired(x, y, 0.8, 1.25, transform=np.log)
    res_sas = (0.0031, (3.38, 0.0031), (-5.90, 0.00005))
    assert_almost_equal(res1[0], res_sas[0], 3)
    assert_almost_equal(res1[1:], res_sas[1:], 2)
    #result R tost
    assert_almost_equal(res1[0], tost_s_paired.p_value, 13)
コード例 #7
0
ファイル: test_tost.py プロジェクト: rogerlew/statsmodels
    def __init__(self):
        self.res2 = tost_clinic_paired_1
        x1, x2 = clinic[:15, 2], clinic[15:, 2]
        self.res1 = Holder()
        res = smws.tost_paired(x1, x2, -0.6, 0.6, transform=None)
        self.res1.pvalue = res[0]
        #self.res1.df = res[1][-1] not yet
        res_ds = smws.DescrStatsW(x1 - x2, weights=None, ddof=0)
        #tost confint 2*alpha TODO: check again
        self.res1.confint_diff = res_ds.confint_mean(0.1)
        self.res1.confint_05 = res_ds.confint_mean(0.05)
        self.res1.mean_diff = res_ds.mean
        self.res1.std_mean_diff = res_ds.std_mean

        self.res2b = ttest_clinic_paired_1
コード例 #8
0
ファイル: test_tost.py プロジェクト: QuocTran/statsmodels
    def __init__(self):
        self.res2 = tost_clinic_paired_1
        x1, x2 = clinic[:15, 2], clinic[15:, 2]
        self.res1 = Holder()
        res = smws.tost_paired(x1, x2, -0.6, 0.6, transform=None)
        self.res1.pvalue = res[0]
        #self.res1.df = res[1][-1] not yet
        res_ds = smws.DescrStatsW(x1 - x2, weights=None, ddof=0)
        #tost confint 2*alpha TODO: check again
        self.res1.confint_diff = res_ds.confint_mean(0.1)
        self.res1.confint_05 = res_ds.confint_mean(0.05)
        self.res1.mean_diff = res_ds.mean
        self.res1.std_mean_diff = res_ds.std_mean

        self.res2b = ttest_clinic_paired_1
コード例 #9
0
ファイル: test_tost.py プロジェクト: rogerlew/statsmodels
 def __init__(self):
     self.res2 = tost_clinic_paired
     x, y = clinic[:15, 3], clinic[15:, 3]
     self.res1 = Holder()
     res = smws.tost_paired(x, y, -0.6, 0.6, transform=None)
     self.res1.pvalue = res[0]
コード例 #10
0
ファイル: test_tost.py プロジェクト: rogerlew/statsmodels
#> cat_items(tt2, prefix="ttest_clinic_indep_1_two_mu_pooled.")
ttest_clinic_indep_1_two_mu_pooled = Holder()
ttest_clinic_indep_1_two_mu_pooled.statistic = -3.299592184135305
ttest_clinic_indep_1_two_mu_pooled.parameter = 28
ttest_clinic_indep_1_two_mu_pooled.p_value = 0.002643203760742494
ttest_clinic_indep_1_two_mu_pooled.conf_int = (-0.35391340938235,
                                               0.6832467427156834)
ttest_clinic_indep_1_two_mu_pooled.estimate = (3.498, 3.333333333333333)
ttest_clinic_indep_1_two_mu_pooled.null_value = 1
ttest_clinic_indep_1_two_mu_pooled.alternative = 'two.sided'
ttest_clinic_indep_1_two_mu_pooled.method = ' Two Sample t-test'
ttest_clinic_indep_1_two_mu_pooled.data_name = 'clinic$var1[1:15] and clinic$var1[16:30]'

res1 = smws.tost_paired(clinic[:15, 2],
                        clinic[15:, 2],
                        -0.6,
                        0.6,
                        transform=None)
res2 = smws.tost_paired(clinic[:15, 3],
                        clinic[15:, 3],
                        -0.6,
                        0.6,
                        transform=None)
res = smws.tost_ind(clinic[:15, 3],
                    clinic[15:, 3],
                    -0.6,
                    0.6,
                    usevar='separate')


class CheckTostMixin(object):
コード例 #11
0
ファイル: test_tost.py プロジェクト: QuocTran/statsmodels
 def __init__(self):
     self.res2 = tost_clinic_paired
     x, y = clinic[:15, 3], clinic[15:, 3]
     self.res1 = Holder()
     res = smws.tost_paired(x, y, -0.6, 0.6, transform=None)
     self.res1.pvalue = res[0]
コード例 #12
0
ファイル: test_tost.py プロジェクト: QuocTran/statsmodels
#> cat_items(tt2, prefix="ttest_clinic_indep_1_two_mu_pooled.")
ttest_clinic_indep_1_two_mu_pooled = Holder()
ttest_clinic_indep_1_two_mu_pooled.statistic = -3.299592184135305
ttest_clinic_indep_1_two_mu_pooled.parameter = 28
ttest_clinic_indep_1_two_mu_pooled.p_value = 0.002643203760742494
ttest_clinic_indep_1_two_mu_pooled.conf_int = (-0.35391340938235, 0.6832467427156834)
ttest_clinic_indep_1_two_mu_pooled.estimate = (3.498, 3.333333333333333)
ttest_clinic_indep_1_two_mu_pooled.null_value = 1
ttest_clinic_indep_1_two_mu_pooled.alternative = 'two.sided'
ttest_clinic_indep_1_two_mu_pooled.method = ' Two Sample t-test'
ttest_clinic_indep_1_two_mu_pooled.data_name = 'clinic$var1[1:15] and clinic$var1[16:30]'




res1 = smws.tost_paired(clinic[:15, 2], clinic[15:, 2], -0.6, 0.6, transform=None)
res2 = smws.tost_paired(clinic[:15, 3], clinic[15:, 3], -0.6, 0.6, transform=None)
res = smws.tost_ind(clinic[:15, 3], clinic[15:, 3], -0.6, 0.6, usevar='separate')


class CheckTostMixin(object):

    def test_pval(self):
        assert_almost_equal(self.res1.pvalue, self.res2.p_value, decimal=13)
        #assert_almost_equal(self.res1.df, self.res2.df, decimal=13)

class TestTostp1(CheckTostMixin):
    #paired var1
    def __init__(self):
        self.res2 = tost_clinic_paired_1
        x1, x2 = clinic[:15, 2], clinic[15:, 2]