比較二或多組變異數Fligner-Killeen檢定 (Fligner-Killeen Test for Comparing Two or More Variances)

套路28: 比較二或多組變異數Fligner-Killeen檢定
 (Fligner-Killeen Test for Comparing Two or More Variances)

1. 使用時機: 用於比較觀測到的兩組或多組變異數(variances)
2. 分析類型: 無母數分析(non-parametric analysis)直接使用資料數值算統計叫parametric方法,把資料排序之後用排序的名次算統計叫non-parametric方法。
3. 前提假設: 無。
4. 資料範例1兩組變異數: 咪路調查高一和大一學生體重(kg)資料如下:
高一
41
35
33
36
40
46
31
37
34
30
38
大一
52
57
62
55
64
57
56
55
60
59

請問高一和大一學生體重變異數是否相同? H0: σ21 = σ22HA: σ21σ22

第一步: 輸入建立資料用小c將資料放入名稱為h1u1vector (R最基本資料結構)。用rep函數產生與資料相同數目的(1110)大寫HU放入名稱為h2u2vector再組合成名稱為datdata frame
  h1 <- c(41, 35, 33, 36, 40, 46, 31, 37, 34, 30, 38)
  u1 <- c(52, 57, 62, 55, 64, 57, 56, 55, 60, 59)
  h2 <- rep("H", 11)
  u2 <- rep("U", 10)
  Weight <- c(h1, u1)
  School <- c(h2, u2)
  dat <- data.frame(Weight, School)

第二步: 畫圖看資料分布。
動作1: 安裝ggplot2程式套件。
動作2: 呼叫ggplot2程式套件備用。
  library(ggplot2)
動作3: 畫圖。
  ggplot(dat, aes(x = School, y = Weight)) +
       geom_boxplot(color = "red")+
       geom_jitter(position = position_jitter(0.05))
  # 同時畫x-y散布(黑色點)圖及盒圖(紅色box plot)
  # ggplot2程式套件geom_jitter函數讓重疊(數值相同)的資料點錯開,避免誤判

第三步: 無母數分析無須檢查資料是否為常態分佈。
第四步: 檢查兩組資料是否為相同變異數(H0: s21 = s22HA: s21s22)
動作1: 閱讀基礎模組(base)fligner.test函數的使用說明。
  help(fligner.test)
動作2: 使用基礎模組(base)fligner.test函數代入dat中資料。
  fligner.test(Weight ~ School, data = dat)
動作3: 判讀結果。
             Fligner-Killeen test of homogeneity of variances
data:  Weight by School
Fligner-Killeen:med chi-squared = 0.41324, df = 1, p-value = 0.5203
  # p-value > 0.05H0: s21 = s22成立資料變異數相同。
  # p-value < 0.05H0: s21 = s22不成立資料變異數不同。

5. 資料範例2多組變異數: 咪路調查餵食不同飼料的肉雞體重(g)資料如下:
飼料1
飼料2
飼料3
飼料4
60.8
68.7
69.6
61.9
67.0
67.7
77.1
64.2
65.0
75.0
75.2
63.1
68.6
73.3
71.5
66.7
61.7
71.8

60.3
H0: σ21 = σ22 = σ23 = σ24 HA: 餵食不同飼料的肉雞體重變異數不完全相同

第一步: 輸入建立資料用小c將資料放入名稱為d1-d4vector (R最基本資料結構)。用rep函數產生與資料相同數目的(45)大寫F1-F4放入名稱為f1-f4vector再組合成名稱為datdata frame
  d1 <- c(60.8, 67.0, 65.0, 68.6, 61.7)
  d2 <- c(68.7, 67.7, 75.0, 73.3, 71.8)
  d3 <- c(69.6, 77.1, 75.2, 71.5)
  d4 <- c(61.9, 64.2, 63.1, 66.7, 60.3)
  f1 <- rep("F1", 5)
  f2 <- rep("F2", 5)
  f3 <- rep("F3", 4)
  f4 <- rep("F4", 5)
  Weight <- c(d1, d2, d3, d4)
  Feed <- c(f1, f2, f3, f4)
  dat <- data.frame(Weight, Feed)

第二步: 畫圖看資料分布。
動作1: 安裝ggplot2程式套件。
動作2: 呼叫ggplot2程式套件備用。
  library(ggplot2)
動作3: 畫圖。
  ggplot(dat, aes(x = Feed, y = Weight)) +
       geom_boxplot(color = "red")+
       geom_jitter(position = position_jitter(0.05))
  # 同時畫x-y散布(黑色點)圖及盒圖(紅色box plot)
  # ggplot2程式套件geom_jitter函數讓重疊(數值相同)的資料點錯開,避免誤判

第三步: 無母數分析無須檢查資料是否為常態分佈。
第四步: 檢查多組資料是否有相同變異數H0: σ21 = σ22 = σ23 = σ24 HA: 餵食不同飼料的肉雞體重變異數不完全相同
動作1: 閱讀基礎模組(base)fligner.test函數的使用說明。
  help(fligner.test)
動作2: 使用基礎模組(base)fligner.test函數代入dat中資料。
  fligner.test(Weight ~ Feed, data = dat)
動作3: 判讀結果。
             Fligner-Killeen test of homogeneity of variances
data:  Weight by Feed
Fligner-Killeen:med chi-squared = 2.005, df = 3, p-value = 0.5714
  # p-value > 0.05H0: σ21 = σ22 = σ23 = σ24成立資料變異數相同。
  # p-value < 0.05H0: σ21 = σ22 = σ23 = σ24不成立資料變異數不同。

來勁了嗎? 想知道更多?? 補充資料(連結):
5. 關於R基礎R繪圖及統計快速入門:
   b. Cookbook for R: http://www.cookbook-r.com/
   d. Statistical tools for high-throughput data analysis (STHDA): http://www.sthda.com/english/
e. The Handbook of Biological Statistics: http://www.biostathandbook.com/
f. An R Companion for the Handbook of Biological Statistics: http://rcompanion.org/rcompanion/index.html
6. Zar, JH. 2010. Biostatistical Analysis, Fifth Edition, Pearson.

留言

這個網誌中的熱門文章

統計不球人 目錄 (Table of Contents)

三因子變異數分析 (Three Way ANOVA)

比較二或多組變異數Levene’s 檢定 (Levene’s Test for Comparing Two or More Variances)