mean1.ttest {SHT}R Documentation

One-sample Student's t-test for Univariate Mean

Description

Given an univariate sample x, it tests

H_0 : \mu_x = \mu_0\quad vs\quad H_1 : \mu_x \neq \mu_0

using the procedure by Student (1908).

Usage

mean1.ttest(x, mu0 = 0, alternative = c("two.sided", "less", "greater"))

Arguments

x

a length-n data vector.

mu0

hypothesized mean \mu_0.

alternative

specifying the alternative hypothesis.

Value

a (list) object of S3 class htest containing:

statistic

a test statistic.

p.value

p-value under H_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.

Examples

## empirical Type 1 error 
niter   = 1000
counter = rep(0,niter)  # record p-values
for (i in 1:niter){
  x = rnorm(10)         # sample from N(0,1)
  counter[i] = ifelse(mean1.ttest(x)$p.value < 0.05, 1, 0)
}

## print the result
cat(paste("\n* Example for 'mean1.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=""))


[Package SHT version 0.1.8 Index]