統計検定の詳しいこと(初歩的なこと)については心理学統計入門(板口・森,2017)を参照ください(Amazonリンク)
result <- t.test(1:10, 2:11)
result
Welch Two Sample t-testdata: 1:10 and 2:11t = -0.73855, df = 18, p-value = 0.4697alternative hypothesis: true difference in means is not equal to 095 percent confidence interval: -3.844662 1.844662sample estimates:mean of x mean of y 5.5 6.5 # read.xlsxで読みこんだデータをdataに保存
library(openxlsx)
data <- read.xlsx("pone.0226832.s001.xlsx")
# 空書データは同じ人から得られたデータなので,対応のあるt検定を使う
# 空書データは空書条件の方が成績が良いという仮説があるため,片側検定を使う
# 例として,空書条件と静止条件の成績を比較する
result2 <- t.test(data$Kusho, data$Static, alternative="greater", paired=T)
result2
Paired t-testdata: data$Kusho and data$Statict = 4.02, df = 25, p-value = 0.0002353alternative hypothesis: true difference in means is greater than 095 percent confidence interval: 0.8626305 Infsample estimates:mean of the differences 1.5 # 実行
# nrowはデータの行数を数えてくれる関数
d1 <- abs(result$statistic)*sqrt((10+10)/10*10)
d2 <- abs(result2$statistic)*sqrt(1/nrow(data))