[R 통계분석] 단일표본 t검정
#1. 방법
t.test(x, y = NULL,
alternative = c("two.sided", "less", "greater"),
mu = 모집단 평균, paired = FALSE, var.equal = FALSE,
conf.level = 0.95, ...)
▶ x에 데이터 입력, y는 입력하지 않음.
▶ mu=모집단평균 옵션 입력 시 단일표본 t검정 수
#2. 예제
> 코드
set.seed(1)
height=rnorm(50,175,5)
population_mean=177
#t검정 수행
#귀무가설 : height = population_mean
t.test(height,mu=population_mean)
#귀무가설 : height < population_mean
t.test(height,mu=population_mean, alternative="greater")
#귀무가설 : height > population_mean
t.test(height,mu=population_mean, alternative="less")
> 실행결과
> t.test(height,mu=population_mean)
One Sample t-test
data: height
t = -2.5477, df = 49, p-value = 0.01403
alternative hypothesis: true mean is not equal to 177
95 percent confidence interval:
174.3208 176.6836
sample estimates:
mean of x
175.5022
> t.test(height,mu=population_mean, alternative="greater")
One Sample t-test
data: height
t = -2.5477, df = 49, p-value = 0.993
alternative hypothesis: true mean is greater than 177
95 percent confidence interval:
174.5166 Inf
sample estimates:
mean of x
175.5022
> t.test(height,mu=population_mean, alternative="less")
One Sample t-test
data: height
t = -2.5477, df = 49, p-value = 0.007015
alternative hypothesis: true mean is less than 177
95 percent confidence interval:
-Inf 176.4879
sample estimates:
mean of x
175.5022
댓글