9.2 One-Group: Mean

The requirements to use the t-test are that (1) the variable is quantitative, (2) the data production employed randomization, and the population distribution is approximately normal. In this section, hypothesis tests with unknown population variance are considered. The test statistic is \[t=\frac{\hat{x}-\mu_0}{s / \sqrt{n}}\] For example, consider the scores from a graduate MPA class which has eighteen students in mpa. The mean of the data is 69 and the sample standard deviation is 21.15. The hypothesis test is formulated as follows: \[ H_0: \mu = 80\\ H_a: \mu \neq 80\] The \(t\)-statistic can be calculated as follows: \[t = \frac{69-80}{21.15/ \sqrt{18}} = -2.207\] The critical value for this two-sided test is -2.11 and thus, the hypothesis is rejected. The hypothesis can aslo be implemented manually in R:

n                   = nrow(mpa)
xbar                = mean(mpa$scores)
stdev               = sd(mpa$scores)
tstatistic          = (xbar-80)/(stdev/sqrt(n))
criticalvalue       = qt(0.025,df=n-1)
pvalue              = pt(tstatistic,n-1)

Or the function t.test() can be used.

t.test(mpa$scores,mu=80)

Similar to the hypothesis tests on proportions, a one-sided test can be implemented with the function t.test() as well. Consider the data in eggweights. Consider the following one-sided hypothesis test: \[ H_0: \mu \geq 63\\ H_a: \mu < 63\] This hypothesis test is implemented as follows:

t.test(eggweights$weight,mu=63,alternative="less")
## 
##  One Sample t-test
## 
## data:  eggweights$weight
## t = -3.4172, df = 60, p-value = 0.0005709
## alternative hypothesis: true mean is less than 63
## 95 percent confidence interval:
##      -Inf 62.00294
## sample estimates:
## mean of x 
##  61.04918

In this case, the null hypothesis is rejected because the p-value is below 5%.