(问题已解决; x,y和s1,s2的大小不同)
在R:
x
在STATA和Excel中获得相同的数字
t.test(x,y,alternative="less")
t = -1.6229,p-value = 0.05758
无论我尝试哪种选项,我都无法使用statsmodels.stats.weightstats.ttest_ind或scipy.stats.ttest_ind复制相同的结果.
statsmodels.stats.weightstats.ttest_ind(s1,s2,alternative="two-sided",usevar="unequal")
(-1.8912081781378358,0.066740317997990656,35.666557473974343)
scipy.stats.ttest_ind(s1,equal_var=False)
(array(-1.8912081781378338),0.066740317997990892)
scipy.stats.ttest_ind(s1,equal_var=True)
(array(-1.8912081781378338),0.066664507499812745)
必须有成千上万的人使用Python来计算t检验.我们都得到不正确的结果吗? (我通常依赖Python,但这次我用STATA检查了我的结果).