Statistical Hypothesis Testing with SAS and R

by Dirk Taeger and Sonja Kuhnt

(c) John Wiley & Sons, Ltd

Test 2.1.2: One-sample t-test

Description:

Tests if a promotion mean \(\mu\) differ from a specific value \(\mu_0\).

Assumptions:

Hypotheses:

  1. \(H_0\) : \(\mu = \mu_0\) vs \(H_1\) : \(\mu \neq \mu_0\).
  2. \(H_0\) : \(\mu \le \mu_0\) vs \(H_1\) : \(\mu \gt \mu_0\).
  3. \(H_0\) : \(\mu \ge \mu_0\) vs \(H_1\) : \(\mu \lt \mu_0\).

Test statistic:

\[T = \frac{\bar{X} - \mu_0}{s}\sqrt{n}\] with \[s = \sqrt{\frac{1}{n-1}\sum_{i=1}^n (X_i - \bar{X})^2}\]

and \[\bar{X} = \frac{1}{n}\sum_{i=1}^n X_i\]

Test decision:

Rejection \(H_0\) if for the observed value t of T:

  1. \(t \lt t_{\alpha/2, n-1}\) or \(t \gt t_{1-\alpha/2, n-1}\)

  2. \(t \gt t_{1-\alpha, n-1}\)

  3. \(t \lt t_{\alpha,n-1}\)

P-value:

  1. \(\rho = 2P(T \le (-|t|))\)

  2. \(\rho = 1 - P(T \le t)\)

  3. \(\rho = P(T \le t)\)

Annotation:

Example

To test the hypothesis that the mean systolic blood pressure in a certain population equals 140 mmHg. The dataset at hands has measurements on 55 patients.

#Blood_pressure dataset
no <- seq(1:55)
status <- c(rep(0, 25), rep(1, 30))
mmhg <- c(120,115,94,118,111,102,102,131,104,107,115,139,115,113,114,105,
          115,134,109,109,93,118,109,106,125,150,142,119,127,141,149,144,
          142,149,161,143,140,148,149,141,146,159,152,135,134,161,130,125,
          141,148,153,145,137,147,169)
blood_pressure <-data.frame(no,status,mmhg)
t.test(blood_pressure$mmhg,mu=140,alternative="two.sided")
## 
##  One Sample t-test
## 
## data:  blood_pressure$mmhg
## t = -3.8693, df = 54, p-value = 0.0002961
## alternative hypothesis: true mean is not equal to 140
## 95 percent confidence interval:
##  124.8185 135.1815
## sample estimates:
## mean of x 
##       130
t.test(blood_pressure$mmhg,mu=140,alternative="less")
## 
##  One Sample t-test
## 
## data:  blood_pressure$mmhg
## t = -3.8693, df = 54, p-value = 0.0001481
## alternative hypothesis: true mean is less than 140
## 95 percent confidence interval:
##      -Inf 134.3253
## sample estimates:
## mean of x 
##       130
t.test(blood_pressure$mmhg,mu=140,alternative="great")
## 
##  One Sample t-test
## 
## data:  blood_pressure$mmhg
## t = -3.8693, df = 54, p-value = 0.9999
## alternative hypothesis: true mean is greater than 140
## 95 percent confidence interval:
##  125.6747      Inf
## sample estimates:
## mean of x 
##       130

Remarks:

  • \(mu=value\) is optional and defines the value \(mu_0\) to test against. Default is 0.
  • \(alternative="value"\) is optional and defines the type of alternative hypothesis: “two.sided”= two sided (A); “greater”=true mean is greater (B); “less”=true mean is lower (C). Default is “two.sided”.