raphaelvallat / pingouin

Statistical package in Python based on Pandas
https://pingouin-stats.org/
GNU General Public License v3.0
1.63k stars 139 forks source link

Does pingouin.compute_esci work also for Glass' delta? #256

Open Federico2111 opened 2 years ago

Federico2111 commented 2 years ago

On the pingouin.compute_esci, I can read that the confidence interval can be calculated for Cohen's d or Hedges' g: https://pingouin-stats.org/generated/pingouin.compute_esci.html Does it work also for Glass' delta, which is a Cohen-type effect size similar to the other two? If so, I think it should be specified.

Thanks

raphaelvallat commented 2 years ago

Hi @Federico2111,

It does not!

Thanks, Raphael

Federico2111 commented 2 years ago

Thanks for replying @raphaelvallat.

Could you please explain why it does not work for Glass' delta, if it is a Cohen-type effect size?

It might be worth adding that feature: maybe this issue could be turned into a feature request. Glass' delta is an important effect size, to be used when two distributions have unequal variances, which can happen experimentally. Cohen's d and Hedges' g should not be used in that case, as the literature advises.

Since there is a roadmap for another stable release of pingouin, which includes also additions to the "esci" library, it might worth adding the parametric ci for Glass' delta.

I hope this helps.

raphaelvallat commented 2 years ago

Hi @Federico2111,

I did not implement it because I wanted to focus on the most widely-used effect size. Also, I assume that the users will need to specify which variable is the control group and which variable is the patient group, which will add a layer of complexity to the function (need to add extra parameters).

Could you please find scientific references as well as a reference software (SPSS, JAMOVI, R) that implements the parametric CI for the Glass delta effect size? Can a reasonable approximation be obtained using the same formula as the Cohen's d effect size?

Thanks, Raphael

Federico2111 commented 2 years ago

Hi @raphaelvallat,

How much reasonable and accurate is the approximation to use Cohen's d parametric CI on Glass' delta is a question for the statistics experts, who hopefully will help us out here. I suppose it depends on how much unequal the variances of the two groups are?

Speaking of the parametric CI around Glass' delta:

This article can be useful: https://digitalcommons.wayne.edu/cgi/viewcontent.cgi?article=1256&context=jmasm “As shown in this article, an alternative interval based on the noncentral t distribution can be used when the standard deviation for one of the groups is used in the denominator, as would be done if Glass’s (1976) ES were used or if the recommendation of Glass et al. (1981) were used when the variances are not homogeneous.”

This other article shows how to calculate the variance for Glass’ delta, which can be used to calculate the parametric CI: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6562325/ Note that, in the pingouin.compute_esci library, the effect size has to be inputted by the user, who could easily calculate Glass’ delta by himself, since the formula is very easy. But he would have to specify which is the control/pre-measurement group, because it is necessary to properly use the sample sizes in the formula to calculate the CI – note the difference in how the variance for Cohen's d and Glass' delta are calculated.

This dissertation as well explains how to calculate the CI around Glass’ delta: https://commons.erau.edu/cgi/viewcontent.cgi?referer=&httpsredir=1&article=1062&context=db-theses

In R, apparently they calculate the CI around Glass’ delta using the pooled standard deviation, i.e. similarly to Hedges’ g: https://easystats.github.io/effectsize/reference/cohens_d.html

Federico2111 commented 2 years ago

@raphaelvallat,

I will add the following comment. You mentioned that the problem with Glass' delta is that the user has to specify which is the control group, thus another parameter has to be added to the libraries. However, I don't think that is necessarily the case.

In the calculation of the effect size (pingouin.compute_effsize), the user could be told that the active group is the first one inputted (x), while the control group is the second one inputted (y). That is all you need to know to calculate Glass' delta.

Similarly, in the calculation of the CI (pingouin.compute_esci), the user could be told that the size of the active group is the first one inputted (nx), while that of the control group is the second one inputted (ny). That is all you need to know to calculate Glass' delta parametric CI.

raphaelvallat commented 2 years ago

Good idea — I agree. Unfortunately, I won't have the time to implement this in the near future, but I'll leave it open if anyone wants to submit a pull request.

Thanks, Raphael

Federico2111 commented 2 years ago

Thanks, I agree.

I could see that you have created a roadmap for the next release of pingouin, where you have included some of my suggestions, for example the parametric CI around eta squared. Do you have any idea about the timing, i.e. when this next version of pingouin will be ready?

raphaelvallat commented 2 years ago

Hi @Federico2111,

I became a father last week and will be on paternity leave for a few weeks. I would say the next version of Pingouin will be released at the earliest in June. The best way to help speed us this process is to submit pull requests to implement the proposed changes.

Thanks, Raphael

Federico2111 commented 2 years ago

Thanks @raphaelvallat and enjoy your paternity leave