Martin Livingstone 2016-12-09
The ToothGrowth dataset from the R UsingR library has been analysed. Two-sample t-tests were used to compare the effect of vitamin C dosage and delivery method on tooth length.
The ToothGrowth dataset contains data from a study on the effect of Vitamin C on tooth growth in 60 guinea pigs.
# Read in the ToothGrowth data
library(UsingR); data("ToothGrowth")
#Basic summary of data
str(ToothGrowth); table(ToothGrowth$supp,ToothGrowth$dose)
## 'data.frame': 60 obs. of 3 variables:
## $ len : num 4.2 11.5 7.3 5.8 6.4 10 11.2 11.2 5.2 7 ...
## $ supp: Factor w/ 2 levels "OJ","VC": 2 2 2 2 2 2 2 2 2 2 ...
## $ dose: num 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 ...
##
## 0.5 1 2
## OJ 10 10 10
## VC 10 10 10
There are 60 observations containing 6 different sample sets of n=10, one for each combination of dose (0.5, 1.0, 2.0 mg/day) and supplement (i.e. delivery method) (OJ - Orange Juice; VJ - Asorbic Acid).
ggplot(data = ToothGrowth, aes(x = supp, y = len)) +
geom_boxplot(aes(fill = supp)) + facet_wrap(~dose) + theme_bw()
The above box plot of the ToothGrowth data shows the effect of Vitamin C on tooth length by dose (0.5, 1.0, 2.0 mg/day) and delivery method (supp). The plot suggests the following:
We can use t-tests to see if the differences suggested above are statistically significant.
The null hypoothesis is that the dosage and supplement do not affect tooth length. The alternative hypothesis is that they do: \[H_0: \mu_1 = \mu_2\] \[H_1: \mu_1 \neq \mu_2\] \(H_0\) will be tested using t-tests for each combination of dose and for each supplement type. The level of significance we use is \(\alpha = 0.05\). We assume:
Is the mean tooth length affected by the dosage when supp is VC?
# Asorbic acid (VC) as the delivery method
vcA <- ToothGrowth %>% filter(dose %in% c(0.5,1.0), supp == "VC")
vcB <- ToothGrowth %>% filter(dose %in% c(1.0,2.0), supp == "VC")
vcC <- ToothGrowth %>% filter(dose %in% c(0.5,2.0), supp == "VC")
rbind(
t.test(len~dose, paired=F, var.equal=F, data=vcA)$conf.int[1:2],
t.test(len~dose, paired=F, var.equal=F, data=vcB)$conf.int[1:2],
t.test(len~dose, paired=F, var.equal=F, data=vcC)$conf.int[1:2] )
## [,1] [,2]
## [1,] -11.26571 -6.314288
## [2,] -13.05427 -5.685733
## [3,] -21.90151 -14.418488
\(H_0\) should be rejected for all three dose combinations when supp is VC.
Is the mean tooth length affected by the dosage when supp is OJ?
# Orange juice (OJ) as the delivery method
ojA <- ToothGrowth %>% filter(dose %in% c(0.5,1.0), supp == "OJ")
ojB <- ToothGrowth %>% filter(dose %in% c(1.0,2.0), supp == "OJ")
ojC <- ToothGrowth %>% filter(dose %in% c(0.5,2.0), supp == "OJ")
rbind(
t.test(len~dose, paired=F, var.equal=F, data=ojA)$conf.int[1:2],
t.test(len~dose, paired=F, var.equal=F, data=ojB)$conf.int[1:2],
t.test(len~dose, paired=F, var.equal=F, data=ojC)$conf.int[1:2] )
## [,1] [,2]
## [1,] -13.415634 -5.5243656
## [2,] -6.531443 -0.1885575
## [3,] -16.335241 -9.3247594
\(H_0\) should be rejected for all three dose combinations when supp is OJ.
Is the mean tooth length affected by the delivery method (Asorbic Acid or Orange Juice)?
dose0.5 <- ToothGrowth %>% filter(dose == 0.5)
dose1.0 <- ToothGrowth %>% filter(dose == 1.0)
dose2.0 <- ToothGrowth %>% filter(dose == 2.0)
rbind(
t.test(len~supp, paired=F, var.equal=F, data=dose0.5)$conf.int[1:2],
t.test(len~supp, paired=F, var.equal=F, data=dose1.0)$conf.int[1:2],
t.test(len~supp, paired=F, var.equal=F, data=dose2.0)$conf.int[1:2] )
## [,1] [,2]
## [1,] 1.719057 8.780943
## [2,] 2.802148 9.057852
## [3,] -3.798070 3.638070
\(H_0\) should be rejected for doses of 0.5 and 1.0 mg/day. However it should not be rejected for doses of 2.0 mg/day.