The aim of this project is to analyze the ToothGrowth data in the R datasets package. Using the tools of exploratory analyses and t-tests, I tend to compare tooth growth by different supplements and doses.
The data consists of measurements of the mean length of the odontoblast cells harvested from the incisor teeth of a population of 60 guinea pigs. These animals were divided into 6 groups of 10 and consistently fed a diet with one of 6 Vitamin C supplement regimes for a period of 42 days. The Vitamin C was administered either in the form of Orange Juice (OJ) or chemically pure Vitamin C in aqueous solution (VC). Each animal received the same daily dosage of Vitamin C (either 0.5, 1.0 or 2.0 milligrams) consistently. After 42 days, their incisor teeth were harvested and subject to analysis via optical microscopy to determine the length (in microns) of the odontoblast cells. For more references, see the article of E. W. CBAMPTON in 1946.
library(ggplot2)
ggplot(data = ToothGrowth, aes(x = factor(dose), y = len, fill = supp)) +
geom_boxplot(width = 0.6) +
ggtitle("ToothGrowth Data") +
labs(y = "Length of Odontoblast Cells", x = "Dosage of Vitamin C",
fill = "Vitamin C Type") +
scale_y_continuous(breaks = seq(0, 35, by = 5) ) +
theme(plot.title = element_text(size = 18, face="bold", color="blue",
hjust = 0.5, vjust = 5)) +
theme(axis.title.y = element_text(size = 12) ) +
theme(axis.title.x = element_text(size = 12) )
From the above panel plot, we can see the dose might have some effects on the length of odontoblast cells: for both Vitamin C supplement and Orange Juice groups, as the dose increases, the odontoblast cells tend to become longer.
While the effect of Vitamin C supplement and Orange Juice depends on the dosage level of Vitamin C: for the dose level of 2.0 milligrams, odontoblast cells in the Orange Juice group are similar as those in Vitamin C supplement groups, although the variance in the former group is smaller; for the dose level of 0.5 and 1.0 milligrams, odontoblast cells in the Orange Juice group tend to be a little longer than those in Vitamin C supplement groups.
summary(ToothGrowth)
## len supp dose
## Min. : 4.20 OJ:30 Min. :0.500
## 1st Qu.:13.07 VC:30 1st Qu.:0.500
## Median :19.25 Median :1.000
## Mean :18.81 Mean :1.167
## 3rd Qu.:25.27 3rd Qu.:2.000
## Max. :33.90 Max. :2.000
The summary of the data are shown in the above output. As it says in the background section, there are 60 observation of the length of odontoblast cells in total. Two factors are controlled in this experiment: 2 types of supplement and 3 levels of doses.
var.test(len~supp, data=ToothGrowth)$p.value
## [1] 0.2331433
# variances of tooth length are equal between different supplements
t.test(len~supp, data=ToothGrowth, var.equal=T)$p.value
## [1] 0.06039337
t.test(len~supp, data=ToothGrowth, var.equal=T)$conf.int
## [1] -0.1670064 7.5670064
## attr(,"conf.level")
## [1] 0.95
First a F-test is applied to compare the variances of tooth growth between different supplements. The p-value of this test is 0.233, implying their variances are equal, so we set option var.equal=T in the following t.test.
The two-sided independent t.test is to compare the tooth growth by supplements. The p-value of t.test is 0.06 and 95% confidence interval of the t.test contains the value of 0. If we set type I error rate (alpha level) as 0.05, we fail to reject the null hypothesis, which means Vitamin C supplement and Orange Juice have similar effects on tooth growth (the differences between Vitamin C supplement and Orange Juice is insignificant).
bartlett.test(len~dose, data=ToothGrowth)$p.value
## [1] 0.7169612
# variances of tooth length are equal among different doses
set1 <- subset(ToothGrowth, dose %in% c(0.5, 1))
set2 <- subset(ToothGrowth, dose %in% c(0.5, 2))
set3 <- subset(ToothGrowth, dose %in% c(1, 2))
t.test(len~dose, data=set1, var.equal=T)$p.value
## [1] 1.266297e-07
t.test(len~dose, data=set2, var.equal=T)$p.value
## [1] 2.837553e-14
t.test(len~dose, data=set3, var.equal=T)$p.value
## [1] 1.810829e-05
Bartlett’s test (see Snedecor and Cochran, 1989) is used to test if k samples are from populations with equal variances. The p-value of this test is 0.717, implying variance s of tooth growth among different doses are the same, so we set option var.equal=T in the following T-test.
Because dose have three levels, we need to conduct 3 pairwise two-sided t.tests to compare tooth growth by different doses. The p-value of those tests are 1.3e-07, 2.8e-14 and 1.8e-5 respectively. If we control family-wise error rate (FWER) of the multiple t-tests by Bonferroni correction (the most conservative method), we need to adjust the type I error rate (alpha level) as 0.05/3. However, our p-value is pretty small, and even under Bonferroni correction we can conclude that doses have significant effects on the tooth growth.
At alpha level of 0.05, We can conclude that the differences of tooth growth under supplements of Vitamin C and Orange Juice are insignificant, while different doses of supplements have significant effects on the tooth growth.
The assumption need for the above conclusions is: the length of odontoblast cells among different supplements and doses follow normal distributions with equal variances.