Category Archives: analysis

t.test – conduct T-test

t.test- conduct T-test T検定
使用例1: t.test(DV, mu=VALUE)
使用例2: t.test(group1, group2)
概要1: one-sample t検定
概要2: two-sample t検定
備考: 片側検定や等分散に関しては下の例を参考にしてください
関連:

# usage #
t.test(DV,mu=VALUE)
t.test(group1,group2)
##### ----- examples ----- #####
# one-sample t検定 (両側検定)
> DV=c(142,108,104,138,105,105,88,86,118,132)
> t.test(DV,mu=100)

	One Sample t-test

data:  DV
t = 2.0385, df = 9, p-value = 0.07194
alternative hypothesis: true mean is not equal to 100
95 percent confidence interval:
  98.61766 126.58234
sample estimates:
mean of x 
    112.6 

# one-sample t検定 (片側検定)
# DVの値が有意にmu=100より高いか検定。
# 低いか検定する場合は、「alternative="less"」
> t.test(DV,mu=100,alternative="greater")

	One Sample t-test

data:  DV
t = 2.0385, df = 9, p-value = 0.03597
alternative hypothesis: true mean is greater than 100
95 percent confidence interval:
 101.2696      Inf
sample estimates:
mean of x 
    112.6 

# two-sample t検定 (等分散を仮定する場合)
> group1=c(142,108,104,138,105,105,88,86,118,132)
> group2=c(92,89,83,118,79,110,119,102,87,55)
> t.test(group1,group2,var.equal=T)

	Two Sample t-test

data:  group1 and group2
t = 2.1927, df = 18, p-value = 0.04171
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
  0.8033645 37.5966355
sample estimates:
mean of x mean of y 
    112.6      93.4 

# two-sample t検定 (等分散を仮定しない場合 - Welch 2 sample t-test)
> group3=c(142,108,104,138,105,105,88,86,118,132)
> t.test(group1,group3)

	Welch Two Sample t-test

data:  group1 and group3
t = 0, df = 18, p-value = 1
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -18.36462  18.36462
sample estimates:
mean of x mean of y 
    112.6     112.6 
##### ----- end examples ----- #####