Sử dụng F test bằng R
Liên hệ:
Facebook: R stats
Email: research@raisinghopevn.com
Điện thoại: 0965276046
Số liệu mẫu
df = ToothGrowth
head(df)## len supp dose
## 1 4.2 VC 0.5
## 2 11.5 VC 0.5
## 3 7.3 VC 0.5
## 4 5.8 VC 0.5
## 5 6.4 VC 0.5
## 6 10.0 VC 0.5
Kiểm tra phân bố chuẩn
shapiro.test(df$len)##
## Shapiro-Wilk normality test
##
## data: df$len
## W = 0.96743, p-value = 0.1091
Vì p=0.1>0.05, nên ta có thể chấp nhận giả thuyết biến len có phân bố chuẩn Lúc này, việc áp dụng F test là phù hợp.
F test
Sử dụng F test bằng hàm var.test()
var.test(len~supp, data = df)##
## 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
Kết quả p=0.2>0.05, ta kết luận phương sai của len giữa 2 nhóm supp là đồng nhất.
Hết phần F test!