Statsmodels plot_simultaneous comparriosn_name not working

429 Views Asked by At

I am using Tukeys pairwise comparison in statsmodels to visualize differences between groups. The code works fine when I run it like this:

from statsmodels.stats.multicomp import pairwise_tukeyhsd
from matplotlib import pyplot as plt 
import numpy as np 
import matplotlib

%matplotlib notebook
fig,ax = plt.subplots()
T = np.asanyarray([1,2,0,1,2,3,4,5,10])
N = np.asanyarray(['a','a','a','b','b','b','c','c','c'])

tk = pairwise_tukeyhsd(T,N)
tk.plot_simultaneous(ax=ax)

It outputs enter image description here

However, when I try to use comparison_name ='c':

tk.plot_simultaneous(comparison_name ='c',ax=ax)

It fails and I get the following traceback:

TypeError                                 Traceback (most recent call last)
<ipython-input-10-9d84068180f9> in <module>()
     19 
     20 tk = pairwise_tukeyhsd(T,N)
---> 21 tk.plot_simultaneous(comparison_name ='c',ax=ax)

C:\Anaconda3\lib\site-packages\statsmodels\sandbox\stats\multicomp.py in plot_simultaneous(self, comparison_name, ax, figsize, xlabel, ylabel)
    733                 if self.groupsunique[i] == comparison_name:
    734                     continue
--> 735                 if (min(maxrange[i], maxrange[midx]) -
    736                                          max(minrange[i], minrange[midx]) < 0):
    737                     sigidx.append(i)

TypeError: only integer scalar arrays can be converted to a scalar index

How can I fix this?

0

There are 0 best solutions below