본문 바로가기
4. 평균비교(2집단) | 모수/2) 독립표본 t검정

[R 통계분석] 독립표본 t 검정 | 이분산 가정

by makhimh 2019. 11. 29.
반응형

[R 통계분석] 독립표본 t 검정 | 이분산 가정


#1. 방법


t.test(x, y = NULL,
       alternative = c("two.sided", "less", "greater"),
       mu = 0, paired = FALSE, var.equal = FALSE,
       conf.level = 0.95, ...)


x,y 자리에 데이터 입력함.

var.equal=FALSE 가 디폴트 값, 이분산 가정 t검정을 수행.

이분산가정 t검정을 Welch's t-test라고 부름.



#2. 예제


> 코드


#데이터 생성
set.seed(1)
height_male=rnorm(50,175,5)
height_female=rnorm(50,165,5)
#t검정 수행
#귀무가설 : height_male = height_female
t.test(height_male, height_female)

#귀무가설 : height_male < height_female
t.test(height_male, height_female, alternative="greater")

#귀무가설 : height_male > height_female
t.test(height_male, height_female, alternative="less")


> 실행결과


> t.test(height_male,height_female)

    Welch Two Sample t-test

data:  height_male and height_female
t = 10.984, df = 95.793, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
  8.123654 11.707564
sample estimates:
mean of x mean of y
 175.5022  165.5866


> t.test(height_male,height_female,alternative="greater")

    Welch Two Sample t-test

data:  height_male and height_female
t = 10.984, df = 95.793, p-value < 2.2e-16
alternative hypothesis: true difference in means is greater than 0
95 percent confidence interval:
 8.41625     Inf
sample estimates:
mean of x mean of y
 175.5022  165.5866


> t.test(height_male,height_female,alternative="less")

    Welch Two Sample t-test

data:  height_male and height_female
t = 10.984, df = 95.793, p-value = 1
alternative hypothesis: true difference in means is less than 0
95 percent confidence interval:
     -Inf 11.41497
sample estimates:
mean of x mean of y
 175.5022  165.5866


반응형

댓글