在STHDA網(wǎng)站Comparing Variances in R 一文中哎榴,專門對正態(tài)性檢驗做了詳致的說明,翻譯并整理入下:
圖片.png
(一) F檢驗F-Test
F檢驗用于評估兩個總體(A和B)的方差是否相等。
F-Test: Compare Two Variances in R.
> var.test(len ~ supp, data = my_data)
F test to compare two variances
data: len by supp
F = 0.6386, num df = 29, denom df = 29, p-value = 0.2331
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.3039488 1.3416857
sample estimates:
ratio of variances
0.6385951
(二) 比較方差的統(tǒng)計檢驗 Homogeneity of variances
有許多檢驗可以檢測不同組之間方差的均等性(均一性),包括:
- F-test: Compare the variances of two samples. The data must be normally distributed.
- Bartlett’s test: Compare the variances of k samples, where k can be more than two samples. The data must be normally distributed. The Levene test is an alternative to the Bartlett test that is less sensitive to departures from normality.
- Levene’s test: Compare the variances of k samples, where k can be more than two samples. It’s an alternative to the Bartlett’s test that is less sensitive to departures from normality.
- Fligner-Killeen test: a non-parametric test which is very robust against departures from normality.
Bartlett’s test用于測試k個樣本中方差的均勻性,其中k可以大于2叉袍。 適用于正態(tài)分布的數(shù)據(jù)。 當(dāng)數(shù)據(jù)分布為非正態(tài)分布時刽酱,下一部分將描述的Levene檢驗是Bartlett檢驗的更穩(wěn)健的替代方案喳逛。
2.1 Compute Bartlett’s test in R
# Bartlett’s test with one independent variable:
> bartlett.test(weight ~ group, data = PlantGrowth)
Bartlett test of homogeneity of variances
data: weight by group
Bartlett's K-squared = 2.8786, df = 2, p-value = 0.2371
# Bartlett’s test with multiple independent variables:
> bartlett.test(len ~ interaction(supp,dose), data=ToothGrowth)
Bartlett test of homogeneity of variances
data: len by interaction(supp, dose)
Bartlett's K-squared = 6.9273, df = 5, p-value = 0.2261
2.2 Compute Levene’s test in R
library(car)
> # Levene's test with one independent variable
> leveneTest(weight ~ group, data = PlantGrowth)
Levene's Test for Homogeneity of Variance (center = median)
Df F value Pr(>F)
group 2 1.1192 0.3412
27
> # Levene's test with multiple independent variables
> leveneTest(len ~ supp*dose, data = ToothGrowth)
Levene's Test for Homogeneity of Variance (center = median)
Df F value Pr(>F)
group 5 1.7086 0.1484
54
2.3 Compute Fligner-Killeen test in R
> fligner.test(weight ~ group, data = PlantGrowth)
Fligner-Killeen test of homogeneity of variances
data: weight by group
Fligner-Killeen:med chi-squared = 2.3499, df = 2, p-value = 0.3088
參考資料: