1 when p >= .9"-6ren"> 1 when p >= .9"-我正在尝试使用 statsmodels 模块执行多个样本比较和 Tukey HSD,但我不断收到此错误消息,“ValueError: v must be > 1 when p >= .9”。我曾尝试在-6ren">
gpt4 book ai didi

statsmodels 错误消息 : "ValueError: v must be > 1 when p >= .9"

转载 作者:行者123 更新时间:2023-12-04 03:56:19 24 4
gpt4 key购买 nike

我正在尝试使用 statsmodels 模块执行多个样本比较和 Tukey HSD,但我不断收到此错误消息,“ValueError: v must be > 1 when p >= .9”。我曾尝试在互联网上查找可能的解决方案,但无济于事。任何熟悉这个模块的人都可以帮助我破译我做错了什么来提示这个错误。我使用 Python 2.7x 版本和 spyder。以下是我的数据和打印语句的示例。谢谢!

import numpy as np
from statsmodels.stats.multicomp import (pairwise_tukeyhsd,MultiComparison)

###--- Here are the data I am using:
data1 = np.array([ 1, 1, 1, 1, 976, 24, 1, 1, 15, 15780])
data2 = np.array(['lau15', 'gr17', 'fri26', 'bays29', 'dantzig4', 'KAT38','HARV50', 'HARV10', 'HARV20', 'HARV41'], dtype='|S8')

####--- Here's my print statement code:
print pairwise_tukeyhsd(data1, data2, alpha=0.05)

最佳答案

似乎您必须提供比每组单个观察更多的数据,才能使测试正常工作。

最小的例子:

from statsmodels.stats.multicomp import pairwise_tukeyhsd,MultiComparison

data=[1,2,3]
groups=['a','b','c']

print("1st try:")
try:
print(pairwise_tukeyhsd(data,groups, alpha=0.05))
except ValueError as ve:
print("whoops!", ve)


data.append(2)
groups.append('a')
print("2nd try:")
try:
print( pairwise_tukeyhsd(data, groups, alpha=0.05))
except ValueError as ve:
print("whoops!", ve)

输出:
1st try:
/home/user/.local/lib/python3.7/site-packages/numpy/core/fromnumeric.py:3367: RuntimeWarning: Degrees of freedom <= 0 for slice
**kwargs)
/home/user/.local/lib/python3.7/site-packages/numpy/core/_methods.py:132: RuntimeWarning: invalid value encountered in double_scalars
ret = ret.dtype.type(ret / rcount)
whoops! v must be > 1 when p >= .9
2nd try:
Multiple Comparison of Means - Tukey HSD, FWER=0.05
====================================================
group1 group2 meandiff p-adj lower upper reject
----------------------------------------------------
a b 0.5 0.1 -16.045 17.045 False
a c 1.5 0.1 -15.045 18.045 False
b c 1.0 0.1 -18.1046 20.1046 False
----------------------------------------------------

关于statsmodels 错误消息 : "ValueError: v must be > 1 when p >= .9",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53135944/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com