The mean safety audit score of ACME Co. stores in New York (n=200) was 74.3pts February last year. Suppose we decided to sample 22 out of the 200 stores one year later. We find that the sample mean is 78.6pts and the sample standard deviation is 3.2pts. Can we reject the null hypothesis that the sample mean score does not differ from last years true mean? That is to say can we prove that this sample mean is indicative of the population and is explained by probability.
Null hypothesis of a two-tailed test of the population mean is:
where is the hypothesized value of the true population mean
The test statistic or output of the test (t) is defined by the sample mean ( ), size (n), and standard deviation (s).
xbar <- 78.6 # sample mean mu0 <- 74.3 # hypothesized val s <- 3.2 # Sample stdev n <- 22 # Sample size t <- (xbar-mu0)/(s/sqrt(n)) t # test statistic  6.302746
Now to compute the range for the .05 significance level:
a <- .05 #Alpha (significance level) t.half.a <- qt(1-a/2, df=n-1) c(-t.half.a, t.half.a)  -2.079614 2.079614
T, our test statistic of 6.302746 does not lie between the range of -2.079614, and 2.079614. This means we can reject the null hypothesis that the mean score does not differ from last year.