R的t-test檢驗


1.t-test的功能:單因素二水平的假設檢驗。

H0:與我們想過要的結果相反的假設,比如我們想要的是兩組數據的差異性,那么這個假設是:兩組數據沒有差異性。

H1或Ha:備擇假設,與H0假設相反。

2.t-test的前提:正態性和方差齊性

3.R中的t-test的使用。

t.test(x, y = NULL,alternative = c("two.sided", "less", "greater"),mu = 0, paired = FALSE, var.equal = FALSE,conf.level = 0.95, ...)

或 t.test(formula, data, subset, na.action, ...)

> data
  druga drugb
1    10    20
2    11    21
3    13    19
4     9    18
> t.test(data$druga,data$drugb)

    Welch Two Sample t-test

data:  data$druga and data$drugb
t = -8.1742, df = 5.5846, p-value = 0.0002598
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -11.417221  -6.082779
sample estimates:
mean of x mean of y 
    10.75     19.50 
> df
  drug effect
1    1     10
2    1     11
3    1     13
4    1      9
5    2     20
6    2     21
7    2     19
8    2     18
> t.test(effect~drug,data=df)

    Welch Two Sample t-test

data:  effect by drug
t = -8.1742, df = 5.5846, p-value = 0.0002598
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -11.417221  -6.082779
sample estimates:
mean in group 1 mean in group 2 
          10.75           19.50 

結果解讀:

t:t統計值。

df:自由度。

p:H0假設成立的概率。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM