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, ...)

Value

A list with class "htest" containing the following components:

statistic

the value of the t-statistic.

parameter

the degrees of freedom for the t-statistic.

p.value

the p-value for the test.

conf.int

a confidence interval for the mean appropriate to the specified alternative hypothesis.

estimate

the estimated mean or difference in means depending on whether it was a one-sample test or a two-sample test.

null.value

the specified hypothesized value of the mean or mean difference depending on whether it was a one-sample test or a two-sample test.

alternative

a character string describing the alternative hypothesis.

method

a character string indicating what type of t-test was performed.

data.name

a character string giving the name(s) of the data.


例題:比較甲、乙兩種安眠藥地療效,將20名患者分成兩組,每組10人,分別服用甲、乙兩種安眠藥,獲得相關數據表所列。一直服用兩種安眠藥後增加地睡眠時間服從方差相同地正態分佈,且兩組實驗相互獨立。顯著性水平\alpha=0.05,試問兩種安眠藥地療效有無顯著差異?

表1 相關數據
類別 延長睡眠時間/小時
服用甲種藥 1.9 0.8 1.1 0.1 0.1 4.4 5.5 1.6 4.6 3.4
服用乙種藥 0.7 -1.6 -0.2 -1.2 -0.1 3.4 3.7 0.8 0.0 2.0

分析:\sigma相同時,假設檢驗爲H_{0}:\mu _{1}=\mu _{2},H_{1}:\mu _{1}\neq \mu _{2}

#函數t.test();
x<-c(1.9,0.8,1.1,0.1,0.1,4.4,5.5,1.6,4.6,3.4)
y<-c(0.7,-1.6,-0.2,-1.2,-0.1,3.4,3.7,0.8,0.0,2.0)
t.test(x,y)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章