Open3
t検定に関してメモ
1標本のt検定
n <- 20
x <- sample(d, n, replace = FALSE)
mean(x)
t.test(x, mu = 145.5)
#> One Sample t-test
#>
#> data: x
#> t = -0.29882, df = 19, p-value = 0.7683
#> alternative hypothesis: true mean is not equal to 145.5
#> 95 percent confidence interval:
#> 143.319 147.136
#> sample estimates:
#> mean of x
#> 145.2275
2標本のt検定
2標本のt検定を行うとき、
- 2つの標本は等分散である
- 正規分布に従う
という2つの条件を満たす必要がある。
1.を満たしているかを検証するときは、バートレットの等分散検定があり、2.の正規性に関してはシャピロ・ウィルクの検定がある
new <- c(2, 3, 6, 7, 4, 5, 6, 3)
old <- c(5, 7, 5, 8, 9, 7, 7, 6)
t.test(new, old, var = TRUE)
#> Two Sample t-test
#>
#> data: new and old
#> t = -2.8259, df = 14, p-value = 0.01347
#> alternative hypothesis: true difference in means is not equal to 0
#> 95 percent confidence interval:
#> -3.9576713 -0.5423287
#> sample estimates:
#> mean of x mean of y
#> 4.50 6.75
-
var=TRUE
: 等分散が満たされる条件下でのt検定を明示
var=FALSE
の時は等分散が満たされないため、ウェルチの検定になる。t.test()
ではFALSE
がデフォルト