pingouin icon indicating copy to clipboard operation
pingouin copied to clipboard

Add Z tests (proportions & means)

Open aurel-p opened this issue 1 year ago • 1 comments

Hi,

1. Intro

As mentioned in discussion #296, it would be convenient to have support for both proportion and mean z tests within pingouin.

statsmodels already provides several methods around those tests but in a confused and dispersed way, so you often end up writing some wrapper. Moreover, those methods sometimes have strange signatures, making it not really straightforward to use. A single and richer pandas output would be far more helpful. We are talking about basics here: in my opinion it would strengthen pingouin's position as a user-friendly but powerful and complete statistical package.

2. Ressources

  • statsmodels

    • Proportions
      • z_stat and p_value: https://www.statsmodels.org/devel/generated/statsmodels.stats.proportion.proportions_ztest.html
      • diff CI: https://www.statsmodels.org/devel/generated/statsmodels.stats.proportion.confint_proportions_2indep.html
      • power: https://www.statsmodels.org/devel/generated/statsmodels.stats.proportion.power_proportions_2indep.html
      • effect size: https://www.statsmodels.org/dev/generated/statsmodels.stats.proportion.proportion_effectsize.html
    • Means
      • z_stat and p_value: https://www.statsmodels.org/stable/generated/statsmodels.stats.weightstats.ztest.html?highlight=ztest#statsmodels.stats.weightstats.ztest OR https://www.statsmodels.org/stable/generated/statsmodels.stats.weightstats.CompareMeans.ztest_ind.html#statsmodels.stats.weightstats.CompareMeans.ztest_ind
      • diff CI: https://www.statsmodels.org/stable/generated/statsmodels.stats.weightstats.zconfint.html?highlight=ztest OR https://www.statsmodels.org/stable/generated/statsmodels.stats.weightstats.CompareMeans.zconfint_diff.html#statsmodels.stats.weightstats.CompareMeans.zconfint_diff
  • R

    • Means
      • Paired Z test: https://rpubs.com/nguyenminhsang/paired_z-test

3. Feature

  • proportions_ztest()

    • parameters

      • x1: 2-column array_like, 1st column: number of trials, 2nd column: number of successes
      • x2: same or proportion value
      • alternative
      • paired
      • r
      • confidence
      • method: method for computing confidence interval, ‘newcomb’ (default), ‘wald’, ‘agresti-caffo’, ‘score’
    • returns

      • Z
      • alternative
      • p_val
      • CI95%: diff in proportion
      • cohen-d
      • BF10
      • power
  • means_ztest()

    • parameters
      • x1: array_like
      • x2: same or mean value
      • alternative
      • paired
      • r
      • confidence
    • returns
      • Z
      • alternative
      • p_val
      • CI95%: diff in means
      • cohen-d
      • BF10
      • power

Thanks! Aurélien

aurel-p avatar Aug 06 '22 11:08 aurel-p

Thanks for the detailed feature request @aurel-p! I won't have the time to implement this in the near future but I'll leave this issue open if anyone wants to give it a first go.

raphaelvallat avatar Aug 11 '22 00:08 raphaelvallat