You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
925 B

3 years ago
install.packages("car")
library(car)
data(anorexia, package = "MASS")
anorexia
# levene 테스트로 등분산성 확인
leveneTest(Postwt~Treat, data = anorexia)
# > leveneTest(Postwt~Treat, data = anorexia)
# Levene's Test for Homogeneity of Variance (center = median)
# Df F value Pr(>F)
# group 2 1.7671 0.1785
# 69
# Pr(>F) = 0.1785, 0.05보다 크므로 귀무가설 채택 (등분산성 만족)
# 분산분석
out1 = aov(Postwt~Treat, data = anorexia)
out1
summary(out1)
# > summary(out1)
# Df Sum Sq Mean Sq F value Pr(>F)
# Treat 2 919 459.5 8.651 0.000444 ***
# Residuals 69 3665 53.1
# p-value 가 0.05보다 작으므로 귀무가설 기각 (각 집단 평균에 차이가 있음)
# ANOVA 분석
out2 = anova(lm(Postwt~Treat, data = anorexia))
out2
summary(out2)
# 일원 분산분석
out3 = oneway.test(Postwt~Treat, data = anorexia)
out3
summary(out3)