我有一个双向方差分析模型,我想在上面运行Holm的方法。我希望看到所有的比较。每个IV有2个级别
import statsmodels.api as sm
from statsmodels.formula.api import ols
model_z = ols('z_esti ~ C(control) + C(agent) + C(control):C(agent)', data=alldata).fit()
z = sm.stats.anova_lm(model_z, typ=2)
z_esti
是响应变量,control
和agent
是预测因子,每个具有2个水平。我知道如何用一个变量执行Holm的方法:
from statsmodels.stats.multicomp import (pairwise_tukeyhsd, MultiComparison)
agentComp = multicomp(alldata['z_esti'], alldata['agent'])
def Holm_Bonferroni(multiComp):
# Instead of the Tukey's test, we can do pairwise t-test
# First, with the "Holm" correction
rtp = multiComp.allpairtest(stats.ttest_rel, method='Holm')
print((rtp[0]))
# and then with the Bonferroni correction
print((multiComp.allpairtest(stats.ttest_rel, method='b')[0]))
# Any value, for testing the program for correct execution
checkVal = rtp[1][0][0,0]
return checkVal
Holm_Bonferroni(agentComp)
我不知道如何处理两个变量。本质上,我不知道如何为多个变量在allpairtest方法中编写groups
kwrg。感谢您的帮助
目前没有回答
相关问题 更多 >
编程相关推荐