当先锋百科网

首页 1 2 3 4 5 6 7

函数介绍

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.90.81.10.10.14.45.51.64.63.4
服用乙种药0.7-1.6-0.2-1.2-0.13.43.70.80.02.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)