***~会飞的蝎子~学习宁静致远 » 日志 » 2-sample ttest and proportion test using R
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)
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
曾经的这一天...
- » 2006年: 真爱!
- » 2005年: 2005年北京引进非北京生源毕业生紧缺专业目录:16个
相关日志:
收藏:
QQ书签
del.icio.us
订阅:
Google
抓虾
