2-sample ttest and proportion test using R

蝎子 发表于 2008-02-25 05:52:17

From HW problems::

 t.test(x, y,alternative ="less",
+  mu = 0, paired = FALSE, var.equal = FALSE, conf.level = 0.95)


output:

      
  Welch Two Sample t-test

data:  x and y
t = -2.3788, df = 10.655, p-value = 0.01863
alternative hypothesis: true difference in means is less than 0
95 percent confidence interval:
      -Inf -5.171432
sample estimates:
mean of x mean of y
     14.5      35.8


Notation:
t.test(x, ...)

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

## S3 method for class 'formula':
t.test(formula, data, subset, na.action, ...)

prop.test(x, n, p = NULL, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, correct = TRUE)

Examples

heads <- rbinom(1, size=100, pr = .5)
prop.test(heads, 100) # continuity correction TRUE by default
1-sample proportions test with continuity correction

data: heads out of 100, null probability 0.5
X-squared = 0.25, df = 1, p-value = 0.6171
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.3703535 0.5719775
sample estimates:
p
0.47

prop.test(heads, 100, correct = FALSE)
1-sample proportions test without continuity correction

data: heads out of 100, null probability 0.5
X-squared = 0.36, df = 1, p-value = 0.5485
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.3751082 0.5671114
sample estimates:
p
0.47


## Data from Fleiss (1981), p. 139.
## H0: The null hypothesis is that the four populations from which
## the patients were drawn have the same true proportion of smokers.
## A: The alternative is that this proportion is different in at
## least one of the populations.

smokers <- c( 83, 90, 129, 70 )
patients <- c( 86, 93, 136, 82 )
prop.test(smokers, patients)

4-sample test for equality of proportions without continuity correction

data: smokers out of patients
X-squared = 12.6004, df = 3, p-value = 0.005585
alternative hypothesis: two.sided
sample estimates:
prop 1 prop 2 prop 3 prop 4
0.9651163 0.9677419 0.9485294 0.8536585
关键词(Tag): 2 test t r sample 110b



收藏: QQ书签 del.icio.us 订阅: Google 抓虾

最新评论

发表评论

* 昵称

已经注册过? 请登录

新用户请先注册 以便能显示头像及追踪评论回复

Email
网址
* 评论
表情
 
 

分类小组论坛
杂谈, 娱乐、八卦, 文学、艺术, 体育, 旅游、同城, 象牙塔, 情感, 时尚、生活, 星座, 科技

请注意遵守中华人民共和国法律法规, 如威胁到本站生存, 将依法向有关部门报告, 同时本站的相关记录可能成为对您不利的证据.

相关法律法规
全国人大常委会关于维护互联网安全的决定
中华人民共和国计算机信息系统安全保护条例
中华人民共和国计算机信息网络国际联网管理暂行规定
计算机信息网络国际联网安全保护管理办法
计算机信息系统国际联网保密管理规定