[R 통계분석] 독립표본 t 검정 | 등분산 가정
#1. 방법
t.test(x, y = NULL,
alternative = c("two.sided", "less", "greater"),
mu = 0, paired = FALSE, var.equal = TRUE,
conf.level = 0.95, ...)
▶ x,y 자리에 데이터 입력함.
▶ var.equal=FALSE 가 디폴트 값, TRUE로 놓으면 등분산가정 t검정 수행.
#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,var.equal=TRUE)
#귀무가설 : height_male < height_female
t.test(height_male, height_female, alternative="greater",var.equal=TRUE)
#귀무가설 : height_male > height_female
t.test(height_male, height_female, alternative="less",var.equal=TRUE)
> 실행결과
> t.test(height_male,height_female,var.equal=TRUE)
Two Sample t-test
data: height_male and height_female
t = 10.984, df = 98, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
8.124171 11.707048
sample estimates:
mean of x mean of y
175.5022 165.5866
> t.test(height_male,height_female,alternative="greater",var.equal=TRUE)
Two Sample t-test
data: height_male and height_female
t = 10.984, df = 98, p-value < 2.2e-16
alternative hypothesis: true difference in means is greater than 0
95 percent confidence interval:
8.41658 Inf
sample estimates:
mean of x mean of y
175.5022 165.5866
> t.test(height_male,height_female,alternative="less",var.equal=TRUE)
Two Sample t-test
data: height_male and height_female
t = 10.984, df = 98, p-value = 1
alternative hypothesis: true difference in means is less than 0
95 percent confidence interval:
-Inf 11.41464
sample estimates:
mean of x mean of y
175.5022 165.5866
'4. 평균비교(2집단) | 모수 > 2) 독립표본 t검정' 카테고리의 다른 글
[R 통계분석] 독립표본 t 검정 | 이분산 가정 (0) | 2019.11.29 |
---|
댓글