반응형

 

/*******************************************************************************************************************
-- Title : [R3.3] 등분산성 테스트 using var.test
-- Reference : http://www.dodomira.com/2016/04/02
-- Key word : 등분산성 var.test p-value 정규성 F-검정 F검정 F테스트 levene.test levenetest levene검정
                  levene 테스트 f-value f value
 *******************************************************************************************************************/

-- Chart

 

-- R

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# ------------------------------
# -- F-검정 using var.test
# ------------------------------
#    t-test를 실시하기 위해서 등분산성, 정규성이 만족되어야 함
#    이를 위해 var.test 검증 필요
 
= c(175168168190156181182175174179)
= c(185169173173188186175174179180)
 
df = data.frame(a,b)
df
 
var.test(a,b)
 # F test to compare two variances
 
 # data:  a and b
 # F = 2.1028, num df = 9, denom df = 9, p-value = 0.2834
 # alternative hypothesis: true ratio of variances is not equal to 1
 # 95 percent confidence interval:
 #     0.5223017 8.4657950
 # sample estimates:
 # ratio of variances 
 #     2.102784 
 # p-value < 0.05 이면 두 집단의 분산이 다르다고 판단 가능.
 # (귀무가설 : 두 분산이 다르다.)
 
summary(df)
 
par(mfrow=c(1,2))
 
plot(a)
plot(b)
 
# ------------------------------
# -- levene 검정 using levene.test or leveneTest(요걸로 대체되었단다.)
# ------------------------------
install.packages("car")
library("car")
 
<- c(61,60,56,63,56,63,59,56,44,61)
<- c(55,54,47,59,51,61,57,54,62,58)
x1 <- data.frame(a,b)
x2 <- stack(x1)
 
leveneTest(values~ind, data=x2)
 # Levene's Test for Homogeneity of Variance (center = median)
 #       Df F value Pr(>F)
 # group  1  0.0039 0.9508
 #       18  
 # p-value(0.9508) < 0.05 이 거짓이므로 두 집단의 분산이 동일하다는 판단 가능.
 # (귀무가설 : 두 분산이 다르다.)
 
cs

 

반응형

+ Recent posts