Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Welch's ANOVA in Python

Tags:

python

scipy

I'm not sure if stackoverflow is the best forum for this, but anyway...

Scipy implements ANOVA using stats.f_oneway, which assumes equal variances. It says in the docs that if the variances are unequal, one could consider the Kruskal-Wallis test instead.

However, what I want is Welch's ANOVA. Scipy has a Welch t-test, but of course this doesn't work if I have more than two groups.

What I find interesting is that scipy used to have stats.oneway which allowed for an equal variance setting. However, it has been deprecated.

Is there an easy way to implement Welch's ANOVA in Python?

like image 538
irene Avatar asked Jun 21 '18 08:06

irene


People also ask

What is Welch's ANOVA?

What is Welch's ANOVA? Welch's ANOVA compares two means to see if they are equal. It is an alternative to the Classic ANOVA and can be used even if your data violates the assumption of homogeneity of variances.


1 Answers

Just required the same thing. I had to copy code from R package. Also requested scipy.stats to add this feature. Here is the ~10 lines of code for the implementation

https://github.com/scipy/scipy/issues/11122

like image 183
Dr. Duke Avatar answered Oct 01 '22 12:10

Dr. Duke