Skip to content

FAQ/DOC/ENH k-sample binomial proportion, joint and individual hypothesis tests #6380

Open

Description

@josef-pkt

https://stackoverflow.com/questions/59566824/one-sided-proportion-test-for-significantly-high-values

Suppose we have k-sample binomial proportions, i.e. 2 x k contingency table with independent columns.

what can we test if the overall hypothesis is that all proportions are the same?

  • joint test: all proportions equal to average proportion
  • individual, vectorized test for equality to average maybe with multiple testing correction, or using joint test as gate keeper to preserve overall FWER, or FDR if some nulls might fail
  • all pairwise, ...

I don't remember what we have for this case. I guess there are some missing hypothesis tests for the k-sample version.

Proper distribution would have to take into account that the average depends on each proportion. There is a literature for this but I don't remember much.

Activity

  1. josef-pkt commented on Jan 3, 2020

    @josef-pkt
    MemberAuthor

    k-sample equality of mean would be just an ANOVA for proportions.
    I'm pretty sure we don't have it.
    But maybe standard ANOVA would apply with pooled variance under the null using normal or chisquare distribution similar to proportions_ztest.

    update I think this is Cochran-Mantel-Hanszel test available in Stratified contingency table.
    I used an example in the meta-analysis notebook for k-sample proportions.

  2. josef-pkt commented on Jan 9, 2020

    @josef-pkt
    MemberAuthor

    R prop.test includes the anova case
    example here
    https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/prop.test

    > smokers  <- c( 83, 90, 129, 70 )
    > patients <- c( 86, 93, 136, 82 )
    > prop.test(smokers, patients)
    
    	4-sample test for equality of proportions without continuity
    	correction
    
    data:  smokers out of patients
    X-squared = 12.6, df = 3, p-value = 0.005585
    alternative hypothesis: two.sided
    sample estimates:
       prop 1    prop 2    prop 3    prop 4 
    0.9651163 0.9677419 0.9485294 0.8536585 
    
  3. josef-pkt commented on Jan 12, 2020

    @josef-pkt
    MemberAuthor

    maybe this is already mostly available

    statsmodels.stats.proportion.proportions_chisquare_allpairs
    proportions_chisquare_pairscontrol
    statsmodels.stats.proportion.proportions_chisquare "This function provides a similar interface to chisquare tests as prop.test in R", docstring mentions contingency tables in scipy.stats but does not mention statsmodels contingency table support (i.e. docstring was never updated)

    no examples, so not immediately obvious what those do, besides guessing based on function names

  4. vsriram11 commented on Jan 13, 2020

    @vsriram11
    Contributor

    Upvoting. Would be great to have a full analog to R's prop.test. I think you're right, it's mostly available, but would be useful/convenient to have a similar API to prop.test, with confidence intervals provided as well.

  5. josef-pkt commented on Jan 13, 2020

    @josef-pkt
    MemberAuthor

    From what I remember R's prop.test handles too many cases in one function. I had tried to split this up into easier to understand functions, but without examples those functions are still not "obvious".

    What confidence intervals are directly related to this? This is a joint test over several independed proportions in the main case. That wouldn't have directly a confidence interval, or does it? The confidence intervals for individual proportions are in a separate function.

    I think we need a structured overview docs for this, so it's easier for users to find which function handles which case.
    It would be helpful if you can figure out what is missing and find a good way to add it.

    aside: The last time I was seriously working on proportions I tried to get everything for the one-sample case
    https://github.com/josef-pkt/misc/blob/proportion_one/notebooks/proportion_one_power.ipynb

    But supporting two- and k- sample cases is still incomplete, even though we already have more than I remembered.

  6. josef-pkt commented on Jan 13, 2020

    @josef-pkt
    MemberAuthor

    About code organization in proportions

    At the time I wrote that code I wanted standalone functions which are also easy to use when we just need a specific item.
    In other cases like weightstats, multiple comparison (tukey-hsd) or contingency tables we used classes which makes it easier to bring everything together in a single place.

    For the stats functions like proportions, I haven't figured out how to better structure it in a class (especially because I also wanted to add power/sample size computations and effectsizes to it)

    What triggered it for me this time was that I couldn't answer a stackoverflow question, because I didn't remember what we have already and whether things we might have would apply to the case in question.

    So it would be good to improve discoverability and usability in this area, and add missing pieces.

  7. josef-pkt commented on Nov 26, 2020

    @josef-pkt
    MemberAuthor

    I just ran into some literature for this, essentially extensions to what we have now for the 2-sample case to the k sample - 2 proportion case. (edit: see next comment)
    I didn't look closely at any of them

    Tang is current article that collects most results, based on quick skimming
    Nam is one of the original, several similar by Gaart, Nam (I guess similar to 2-sample case)
    AFAIU, the null is equal relative risk but not equal to 1 with confidence intervals for it, the part to estimate and confint is closer to meta-analysis applications.

    Tarone is a commonly cited article for score tests with nuisance parameters

    Nam, Jun-Mo. 1994. “Sample Size Requirements for Stratified Prospective Studies with Null Hypothesis of Non-Unity Relative Risk Using the Score Test.” Statistics in Medicine 13 (1): 79–86. https://doi.org/10.1002/sim.4780130109.

    Tang, Yongqiang. 2020. “Score Confidence Intervals and Sample Sizes for Stratified Comparisons of Binomial Proportions.” Statistics in Medicine 39 (24): 3427–57. https://doi.org/10.1002/sim.8674.

    Tarone, Robert E. 1988. “Homogeneity Score Tests with Nuisance Parameters.” Communications in Statistics - Theory and Methods 17 (5): 1549–56. https://doi.org/10.1080/03610928808829697.

    Lipsitz, Stuart R., Keith B. G. Dear, Nan M. Laird, and Geert Molenberghs. 1998. “Tests for Homogeneity of the Risk Difference When Data Are Sparse.” Biometrics 54 (1): 148–60. https://doi.org/10.2307/2534003.
    If I skimmed correctly, then sparse means asymptotic is in large, increasing number of strata.
    Several of the other articles have fixed number of strata and increasing strata/group size

    related

  8. josef-pkt commented on Nov 26, 2020

    @josef-pkt
    MemberAuthor

    to clarify the different setups (AFAICS)

    • 2 x 1 : one sample of one proportion
    • k x 1 : one sample of multinomial proportions
    • 2 x k : k independent samples of a binomial proportion, focus is on individual proportions
    • 2 x 2 : two samples of a binary/binomial proportion
    • 2 x 2 x k : stratified 2 x 2 that's in the last comment and meta-analysis, we have a set of 2x2 comparisons, focus is on the comparison between 2 proportions across "strata"

    in terms of model:
    2 x 2 x k is binary or binomial count endog, one binary exog and a stratification exog. Under the null, there is not interaction between binary exog and stratification variable.

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