適切な統計検定を選ぶ

Pythonで学ぶ実験計画法

James Chapman

Curriculum Manager, DataCamp

適切な検定の選択

 

  • データセットの特徴
    • データ型
    • 分布 → 多くの検定で正規性を仮定
    • 変数数
  • 仮説

結果: 正確で信頼できる結論!

  • t検定、ANOVA、カイ二乗

ツールと本のライブラリ

Pythonで学ぶ実験計画法

データセット:運動成績

  • トレーニング法と食事が運動成績に与える影響
athletic_perf.sample(n=5)
 Athlete_ID  Training_Program     Diet_Type  Initial_Fitness  Performance_Inc 
        167         Endurance   Plant-Based             High         9.113040               
        289         Endurance          Keto              Low        11.039744               
        164         Endurance   Plant-Based           Medium        11.614835              
         30          Strength          Keto           Medium         7.384686               
        186              HIIT  High-Protein              Low         6.776078
Pythonで学ぶ実験計画法

独立2標本t検定

  • _2群_ の平均を比較
  • 仮定: 正規分布、等分散
from scipy.stats import ttest_ind
group1 = athletic_perf[athletic_perf['Training_Program'] == 'HIIT']['Performance_Inc']
group2 = athletic_perf[athletic_perf['Training_Program'] == 'Endurance']['Performance_Inc']

t_stat, p_val = ttest_ind(group1, group2) print(f"T-statistic: {t_stat}, P-value: {p_val}")
T-statistic: 0.20671020082911742, P-value: 0.8364563849070663

p_val > $\alpha$ → 平均差の証拠は不十分

Pythonで学ぶ実験計画法

一元配置分散分析(One-way ANOVA)

  • 複数(>2)群 の平均を比較
  • 仮定: 群間の等分散
from scipy.stats import f_oneway
program_types = ['HIIT', 'Endurance', 'Strength']
groups = [athletic_perf_data[athletic_perf_data['Training_Program'] == program]
['Performance_Increase'] for program in program_types]

f_stat, p_val = f_oneway(*groups) print(f"F-statistic: {f_stat}, P-value: {p_val}")
F-statistic: 1.5270022393256704, P-value: 0.2188859009050602

p_val > $\alpha$ → 平均差の証拠は不十分

Pythonで学ぶ実験計画法

カイ二乗検定(連関)

  • カテゴリ変数 間の関係を検定
  • 分布の仮定なし
from scipy.stats import chi2_contingency
import pandas as pd
contingency_table = pd.crosstab(athletic_perf['Training_Program'],
                                athletic_perf['Diet_Type'])
Diet_Type         High-Protein  Keto  Plant-Based
Training_Program                                 
Endurance                   33    28           33
HIIT                        27    32           40
Strength                    38    29           40
Pythonで学ぶ実験計画法

カイ二乗検定(連関)

chi2_stat, p_val, dof, expected = chi2_contingency(contingency_table)
print(f"Chi2-statistic: {chi2_stat}, P-value: {p_val}")
Chi2-statistic: 2.154450885821988, P-value: 0.7073764021451127

p_val > $\alpha$ → 連関の証拠は不十分

Pythonで学ぶ実験計画法

Vamos praticar!

Pythonで学ぶ実験計画法

Preparing Video For Download...