Search code examples
pythonscipydata-analysis

n-sample test for equality of proportions python


n-sample test for equality of proportions python

This statistical test seems pretty straightforward in R > http://sphweb.bumc.bu.edu/otlt/MPH-Modules/BS/R/R6_CategoricalDataAnalysis/R6_CategoricalDataAnalysis6.html

I looked at scipy, it doesn`t provide statistical tools for more than 2 sample test

I`m looking to a library in python capable of such advanced statistical test.


Solution

  • I assume that what you want to do is a chi-squared test for independence of the proportions between the different classes (see https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test#Testing_for_statistical_independence). You can do this in Python using the function scipy.stats.chi2_contingency (see https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.chi2_contingency.html for documentation).