Exemple #1
0
def test_effectsize_fstat():
    # results from R package `effectsize`, confint is 0.9 confidence
    # > es = F_to_eta2(45.8, 3, 35)
    Eta_Sq_partial = 0.796983758700696
    CI_eta2 = 0.685670133284926, 0.855981325777856  # reformated from output
    # > es = F_to_epsilon2(45.8, 3, 35)
    Epsilon_Sq_partial = 0.779582366589327
    CI_eps2 = 0.658727573280777, 0.843636867987386
    # > es = F_to_omega2(45.8, 3, 35)
    Omega_Sq_partial = 0.775086505190311
    CI_omega2 = 0.65286429480169, 0.840179680453464
    # > es = F_to_f(45.8, 3, 35)
    Cohens_f_partial = 1.98134153686695
    CI_f = 1.47694659580859, 2.43793847155554

    f_stat, df1, df2 = 45.8, 3, 35
    # nobs = df1 + df2 + 1  # not directly used in the following, only df
    fes = smo._fstat2effectsize(f_stat, (df1, df2))
    assert_allclose(np.sqrt(fes.f2), Cohens_f_partial, rtol=1e-13)
    assert_allclose(fes.eta2, Eta_Sq_partial, rtol=1e-13)
    assert_allclose(fes.eps2, Epsilon_Sq_partial, rtol=1e-13)
    assert_allclose(fes.omega2, Omega_Sq_partial, rtol=1e-13)

    ci_nc = confint_noncentrality(f_stat, (df1, df2), alpha=0.1)
    # the following replicates R package effectsize
    ci_es = smo._fstat2effectsize(ci_nc / df1, (df1, df2))
    assert_allclose(ci_es.eta2, CI_eta2, rtol=2e-4)
    assert_allclose(ci_es.eps2, CI_eps2, rtol=2e-4)
    assert_allclose(ci_es.omega2, CI_omega2, rtol=2e-4)
    assert_allclose(np.sqrt(ci_es.f2), CI_f, rtol=2e-4)
Exemple #2
0
def test_effectsize_fstat_stata():
    # reference numbers computed with Stata 14
    # Stata 16 does not seem to have confint for omega2

    # esizei 2 40 7.47403193349075, level(90)
    eta2 = 0.2720398648288652
    lb_eta2 = 0.0742092468714613
    ub_eta2 = 0.4156116886974804
    omega2 = 0.2356418580703085
    lb_omega2 = 0.0279197092150344
    ub_omega2 = 0.3863922731323545
    # level = 90

    f_stat, df1, df2 = 7.47403193349075, 2, 40
    fes = smo._fstat2effectsize(f_stat, (df1, df2))
    assert_allclose(fes.eta2, eta2, rtol=1e-13)
    assert_allclose(fes.omega2, omega2, rtol=0.02)  # low agreement
    ci_es = smo.confint_effectsize_oneway(f_stat, (df1, df2), alpha=0.1)
    assert_allclose(ci_es.eta2, (lb_eta2, ub_eta2), rtol=1e-4)
    assert_allclose(ci_es.ci_omega2, (lb_omega2, ub_omega2), rtol=0.025)