mean2.ttest {SHT} | R Documentation |
Two-sample Student's t-test for Univariate Means
Description
Given two univariate samples x
and y
, it tests
H_0 : \mu_x^2 \left\lbrace =,\geq,\leq \right\rbrace \mu_y^2\quad vs\quad H_1 : \mu_x^2 \left\lbrace \neq,<,>\right\rbrace \mu_y^2
using the procedure by Student (1908) and Welch (1947).
Usage
mean2.ttest(
x,
y,
alternative = c("two.sided", "less", "greater"),
paired = FALSE,
var.equal = FALSE
)
Arguments
x |
a length- |
y |
a length- |
alternative |
specifying the alternative hypothesis. |
paired |
a logical; whether consider two samples as paired. |
var.equal |
a logical; if |
Value
a (list) object of S3
class htest
containing:
- statistic
a test statistic.
- p.value
p
-value underH_0
.- alternative
alternative hypothesis.
- method
name of the test.
- data.name
name(s) of provided sample data.
References
Student (1908). “The Probable Error of a Mean.” Biometrika, 6(1), 1. ISSN 00063444.
Student (1908). “Probable Error of a Correlation Coefficient.” Biometrika, 6(2-3), 302–310. ISSN 0006-3444, 1464-3510.
Welch BL (1947). “The Generalization of ‘Student’s' Problem when Several Different Population Variances are Involved.” Biometrika, 34(1/2), 28. ISSN 00063444.
Examples
## empirical Type 1 error
niter = 1000
counter = rep(0,niter) # record p-values
for (i in 1:niter){
x = rnorm(57) # sample x from N(0,1)
y = rnorm(89) # sample y from N(0,1)
counter[i] = ifelse(mean2.ttest(x,y)$p.value < 0.05, 1, 0)
}
## print the result
cat(paste("\n* Example for 'mean2.ttest'\n","*\n",
"* number of rejections : ", sum(counter),"\n",
"* total number of trials : ", niter,"\n",
"* empirical Type 1 error : ",round(sum(counter/niter),5),"\n",sep=""))