R中检验正态分布的方法:
(1)Kolmogorov–Smirnov test:ks.test(x,y,…)函数
(2)Anderson–Darling test :ad.test(x)函数
(3)Shapiro-Wilk test:shapiro.test(x) 函数。适用于小样本(3≤n≤50)
(4)Lilliefor test:lillie.test(x)函数
R中检验方差齐性的方法:
(1)Bartlett test: 数据符合正态分布,适用此方法。Bartlett.test(x)函数
(2)Levene test:leveneTest(x)函数
(3)Fligner-Killeen test:非参检验方法,不依赖任何分布。Fligner.test(x)函数
#加载包library(car)data(iris)#提取iris,Sepal.Lengthdat<-dplyr::select(iris,Sepal.Length,Species)#正态检验#Sepal.Lengthshapiro.test(dat$Sepal.Length)#整体检验tapply(dat$Sepal.Length,dat$Species, shapiro.test)#分组检验qqPlot(lm(dat$Sepal.Length~dat$Species), simulate = TRUE, main = 'QQ Plot', labels = FALSE)#方差齐性leveneTest(dat$Sepal.Length~dat$Species)#car包leveneTest函数bartlett.test(dat$Sepal.Length~dat$Species)
本文介绍了R语言中检验正态分布和方差齐性的方法。检验正态分布的方法有Kolmogorov–Smirnov test、Anderson–Darling test等,分别对应不同函数;检验方差齐性的方法有Bartlett test、Levene test等,也各有适用情况和对应函数。

2558

被折叠的 条评论
为什么被折叠?



