Skip to content

ENH: effect size and power based on test statistic for other distribution #6983

Open

Description

@josef-pkt

I added power and effect size computation based on F-statistic in oneway PR #6789

We should be able to do the same for other distributions, t-test, chisquare and normal.
Confidence intervals can be obtained through the noncentrality parameter inversion.

For t-test and z-test the effect size will be a variant on cohen's d.
chisquare would also produce something like cohen's f_squared

Under correctly specified MLE assumptions, those might be standard (the usual) effect sizes.
With robust cov_type, Welch, ..., we will get an adjusted version. in analogy to Welch oneway anova based on F-statistic.

Activity

  1. josef-pkt commented on Oct 2, 2020

    @josef-pkt
    MemberAuthor

    for chisquare: estimating non-centrality parameter and confidence interval for it.

    one recommended estimator seems to be nc = max(chi2 - df, 0)
    Note: I didn't use the bias correction for f2 noncentrality and related effect sizes.
    see comments about different eta, omega for that. psychology literature mostly doesn't truncate infeasible negative nc
    (in oneway/anova PR ?)

    usage of nc of chi2 for Hosmer-lemeshow chisquare test in
    Nattino, Giovanni, Michael L. Pennell, and Stanley Lemeshow. 2020. “Assessing the Goodness of Fit of Logistic Regression Models in Large Samples: A Modification of the Hosmer-Lemeshow Test.” Biometrics 76 (2): 549–60. https://doi.org/10.1111/biom.13249.

    refer for nc and interval estimation to
    Kent, John T., and Timothy J. Hainsworth. 1995. “Confidence Intervals for the Noncentral Chi-Squared Distribution.” Journal of Statistical Planning and Inference 46 (2): 147–59. https://doi.org/10.1016/0378-3758(94)00104-4.

    there is a related literature for admissible (non-dominated quadratic risk) estimators for nc
    e.g., but there are more
    Kubokawa, T., C.P. Robert, and A.K.Md.E. Saleh. 1993. “Estimation of Noncentrality Parameters.” Canadian Journal of Statistics 21 (1): 45–57. https://doi.org/10.2307/3315657.

    Saxena, K. M. Lal, and Khursheed Alam. 1982. “Estimation of the Non-Centrality Parameter of a Chi Squared Distribution.” Annals of Statistics 10 (3): 1012–16. https://doi.org/10.1214/aos/1176345892.

    Li, Qizhai, Junjian Zhang, and Shuai Dai. 2009. “On Estimating the Non-Centrality Parameter of a Chi-Squared Distribution.” Statistics & Probability Letters 79 (1): 98–104. https://doi.org/10.1016/j.spl.2008.07.025.

  2. josef-pkt commented on Oct 5, 2020

    @josef-pkt
    MemberAuthor
    alpha_half = 0.025
    special.chndtrinc(chi2, df, [1 - alpha_half, 0.5, alpha_half])
    array([ 0.03337145,  6.47368953, 20.76155068])
    

    for test cases
    Code for a short online book with a chapter on confint for noncentrality parameter of nct, nc-chi2, ncf.
    This should be good for test cases at a few digits precision.
    http://www.michaelsmithson.online/stats/CIstuff/Splusnonc.pdf
    scipy.special precision is higher in round tripping

    I need a collection of functions for this, eg. https://www.statsmodels.org/dev/generated/statsmodels.stats.oneway.confint_noncentrality.html and similar in oneway

    The functions in oneway for this are messy. I cannot figure out quickly which function does what.

    maybe combine in one function:

    • estimate nc from test statistic and df
    • get confint for nc
    • convert to the corresponding common effect sizes (nc/nobs and variants )

    aside: for nc-chi2 the truncated unbiased estimate for nc max(chi2_stat - df, 0) or some variant like max(chi2_stat - df, chi2_stat / (df + 1) (Li et al 2009) looks best Li et al version has better MSE for larger nc and doesn't have mass point at zero.

    For ncf, I didn't like the literature for bias corrected nc estimate, but I should add it I guess. (I haven't checked the serious stats literature for it.)
    One problem with (no) bias is that it doesn't survive nonlinear transformation, e.g. going from f2 to eta2. Median would be preserved but I haven't seen that in any of the related literature.

    question (I haven't tried yet):
    If chi2_stat - df < 0, is the truncated nc=0 outside the interval that we compute by inverting nc-chi2 cdf?
    The lower confidence bound might approximate zero, i.e. low_nc is an epsilon < 1e-20.

  3. josef-pkt commented on Oct 5, 2020

    @josef-pkt
    MemberAuthor

    umvue for ncF
    based on
    Kubokawa, T., C.P. Robert, and A.K.Md.E. Saleh. 1993. “Estimation of Noncentrality Parameters.” Canadian Journal of Statistics 21 (1): 45–57. https://doi.org/10.2307/3315657.

    they also have noncentrality for OLS statistic

    # example from http://www.michaelsmithson.online/stats/CIstuff/Splusnonc.pdf
    # F(4, 75) = 3.5, confidence level = .95, two-sided CI:
    # > lof(3.5,4,75,.95)
    # [1] 0.7781436 0.9750039
    # > hif(3.5,4,75,.95)
    # [1] 29.72949219 0.02499965 
    f_stat, df1, df2 = 3.5, 4, 75
    special.ncfdtrinc(df1, df2, [1 - alpha_half, 0.5, alpha_half], f_stat)
    array([ 0.77826711, 10.85442424, 29.72929426])
    
    # umvue
    x_s = f_stat * df1 / df2  # X / S in article
    nc_f_umvue = (df2 - 2) * x_s - df1
    nc_f_umvue
    9.626666666666667
    
    stats.ncf.mean(df1, df2, nc_f_umvue)  # round trip !
    3.5000000000000004
    

    their improved estimators for nc for ncf
    where nc_0 is the umvue above

    truncated max(nc_0, 0)
    and
    max(nc_0, 2 * (df2 - 2) / (df1 + 2) * (x/s)

  4. josef-pkt commented on Oct 5, 2020

    @josef-pkt
    MemberAuthor

    for nct

    confint

    # t(98) = 1.5, confidence level = .95, two-sided CI:
    # > lot(1.5,98,.95)
    # [1] -0.4749756 0.9750024
    # > hit(1.5,98,.95)
    # [1] 3.467285 0.025005 
    ​
    # > conf.limits.nct(1.5,98,.95)
    #  Lower.Limit Prob.Low.Limit Upper.Limit Prob.Up.Limit
    # Values -0.474934 0.975 3.467371 0.02499999 
    ​
    t_stat, df = 1.5, 98
    special.nctdtrinc(df, [1 - alpha_half, 0.5, alpha_half], t_stat)
    array([-0.47493335,  1.4961639 ,  3.46737272])
    

    I haven't found a reference for an estimate for nc from t-stat yet

    reverse engineering from scipy.stats.nct.mean which has explicit computation for mean
    solving E(y_nct | n_ct) = t_stat for n_ct

    gfac = special.gamma(df/2.-0.5) / special.gamma(df/2.)
    c11 = np.sqrt(df/2.) * gfac
    nc_t = t_stat / c11
    nc_t
    1.4884861311308932
    
    stats.nct.mean(df, nc_t)
    1.5
    

    according to this, mean of nct is close but not equal to nc parameter.

    Note, in contrast to nc-chi2 and nc-F, the nc in nc-t can be negative.

    aside: the gamma values are huge 1e60, so using gammaln would be better, i.e.
    np.exp(special.gammaln(df/2.-0.5) - special.gammaln(df/2.))

    update
    The nct case is in Hedges 1981 on standardized mean diff effect size
    AFAICS (not verified yet), c11 above is the same as the bias correction factor c(m) in Hedges.
    stats.meta_analysis uses the normal approximation to nct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions