One sample t-test for a hypothesized mean
The alternative hypothesis (bilateral or unilateral) are extremely important in this particular test.
t.test{stats}
- var1 is a vector containing the different numerical observations in the sample
- alternative = one of “two.sided”, “less”, “greater”. The parameters defines to define the type of alternative hypothesis to be used: two.sided for bilateral test and “greater” or “less” for unilateral tests.
- mu= value determined the value of the hypothesised mean (default = 0).
The alternative = “less” means that, if we reject the null hypothesis, the alternative hypothesis is that the the true mean of the population is less than the hypothesised mean
t-test single sample
M Claereboudt
October 24, 2015
Let’s first create a vector representing the amount of nitrate found in drinking water from different public sources
v1 <- c(8.75, 9.40, 8.40,10.25, 7.80, 9.05, 9.10,10.50, 8.70, 8.95)
We would like to know if on average the water supply follows the maximum contaminant level (MCL) of 10 mg/l. We want to know if we reject the null hypothesis if the true mean > 10.
t.test(v1, mu = 10, alternative = "greater")
##
## One Sample t-test
##
## data: v1
## t = -3.5666, df = 9, p-value = 0.997
## alternative hypothesis: true mean is greater than 10
## 95 percent confidence interval:
## 8.622287 Inf
## sample estimates:
## mean of x
## 9.09
In this case we used “greater” to test if the mean of the population would be larger than the hypothesised mean (10) As we can see, the p-value is very large, suggesting that in this particular example that the true mean of the population does not exceed 10 mg/l.
In this second example we will look at the minimum conc of a particular antibiotic in the blood stream 6 hours after ingestion. This minimum concentration was experimentally determined as 12.4 µg/l.
v2 <- c(8.75, 7.40, 11.40, 12.6, 10.80, 9.05, 10.10,10.50, 12.70, 8.95)
We would like to know if on average the concentration of antibiotics remains larger than the minimum active concentration (i.e. we do not want it to follow below this level) When we reject the null hypothesis it would indicate that mean < 12.4.
t.test(v2, mu = 12.4, alternative = "less")
##
## One Sample t-test
##
## data: v2
## t = -3.9909, df = 9, p-value = 0.001577
## alternative hypothesis: true mean is less than 12.4
## 95 percent confidence interval:
## -Inf 11.22403
## sample estimates:
## mean of x
## 10.225
In this second test, we have to reject the null hypothesis. The data thus support the alternative hypothesis: the mean of the population is <12.4. At this particular dosage, the concentration of antibiotic is insufficient to be effective.