非参数 ANOVA 与非配对 t 检验

Python 假设检验

James Chapman

Curriculum Manager, DataCamp

Wilcoxon–Mann–Whitney 检验

  • 亦称为Mann-Whitney U 检验
  • 对数值输入 {{1}} 的秩进行 t 检验
  • 适用于非配对数据
Python 假设检验

Wilcoxon–Mann–Whitney 检验设置

age_vs_comp = stack_overflow[['converted_comp', 'age_first_code_cut']]
age_vs_comp_wide = age_vs_comp.pivot(columns='age_first_code_cut',
                                     values='converted_comp')
age_first_code_cut      adult     child
0                     77556.0       NaN
1                         NaN   74970.0
2                         NaN  594539.0
...                       ...       ...
2258                      NaN   97284.0
2259                      NaN   72000.0
2260                      NaN  180000.0

[2261 rows x 2 columns]
Python 假设检验

Wilcoxon–Mann–Whitney 检验

alpha=0.01
import pingouin
pingouin.mwu(x=age_vs_comp_wide['child'], 
             y=age_vs_comp_wide['adult'],
             alternative='greater')
        U-val alternative         p-val       RBC      CLES
MWU  744365.5     greater  1.902723e-19 -0.222516  0.611258
Python 假设检验

Kruskal–Wallis 检验

"Kruskal–Wallis 检验"之于"Wilcoxon–Mann–Whitney 检验",如同"ANOVA"之于"t 检验"

alpha=0.01
pingouin.kruskal(data=stack_overflow, 
                 dv='converted_comp', 
                 between='job_sat')
          Source  ddof1          H         p-unc
Kruskal  job_sat      4  72.814939  5.772915e-15
Python 假设检验

一起练习吧!

Python 假设检验

Preparing Video For Download...