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)
def test_oneway_effectsize(): # examole 3 in Steiger 2004 Beyond the F-test, p. 169 F = 5 df1 = 3 df2 = 76 nobs = 80 ci = confint_noncentrality(F, (df1, df2), alpha=0.05, alternative="two-sided") ci_es = confint_effectsize_oneway(F, (df1, df2), alpha=0.05) ci_steiger = ci_es.ci_f * np.sqrt(4 / 3) res_ci_steiger = [0.1764, 0.7367] res_ci_nc = np.asarray([1.8666, 32.563]) assert_allclose(ci, res_ci_nc, atol=0.0001) assert_allclose(ci_es.ci_f_corrected, res_ci_steiger, atol=0.00006) assert_allclose(ci_steiger, res_ci_steiger, atol=0.00006) assert_allclose(ci_es.ci_f**2, res_ci_nc / nobs, atol=0.00006) assert_allclose(ci_es.ci_nc, res_ci_nc, atol=0.0001)