The response is the length of odontoblasts (cells responsible for tooth growth) in 60 guinea pigs. Each animal received one of three dose levels of vitamin C (0.5, 1, and 2 mg/day) by one of two delivery methods, (orange juice or ascorbic acid (a form of vitamin C and coded as VC).
ToothGrowth data-set provided by the R data-sets package will be put to test. For every different value of dose, a confidence interval for the difference between the different supp (delivery methods) will be extracted; if the CI for the difference contains 0 then we’ll fail to reject the Null Hypothesis, which in this case is that there’s no tooth growth difference between the 2 delivery methods.
| 0.5 | 1 | 2 | |
|---|---|---|---|
| OJ | 10 | 10 | 10 |
| VC | 10 | 10 | 10 |
This table shows equal number of observations for each combination of supp & dose. Let’s look at a box-plot for these 6 different combinations of variables:
It seems like the second delivery method yields lower length until the dose level is 2 mg/day. Let’s generate formal Confidence Intervals for the difference in length between supp groups, by every different dose level. Also, we’ll generate a fourth CI without discerning between dose levels.
d1 <- ToothGrowth[ToothGrowth$dose==.5,1:2] #Length data for 0.5 dose subset.
d2 <- ToothGrowth[ToothGrowth$dose==1 ,1:2] #Length data for 1 dose subset.
d3 <- ToothGrowth[ToothGrowth$dose==2 ,1:2] #Length data for 2 dose subset.
confInts <- rbind(
as.numeric(t.test(len~I(relevel(supp,2)),data=d1)$conf),
as.numeric(t.test(len~I(relevel(supp,2)),data=d2)$conf),
as.numeric(t.test(len~I(relevel(supp,2)),data=d3)$conf),
as.numeric(t.test(len~I(relevel(supp,2)),data=ToothGrowth)$conf)
)
rownames(confInts) <- c("0.5 mg/day","1 mg/day","2 mg/day","Every dose")
colnames(confInts) <- c(NA,NA)
kable(confInts,caption = "Confidence Intervals")
| NA | NA | |
|---|---|---|
| 0.5 mg/day | -8.780943 | -1.7190573 |
| 1 mg/day | -9.057852 | -2.8021482 |
| 2 mg/day | -3.638070 | 3.7980705 |
| Every dose | -7.571016 | 0.1710156 |
The first two CIs show that, for the first two dose levels (0.5 & 1), the orange juice (OJ) delivery method has a greater outcome in length. It is with the last two CIs where we can see a zero contained in them, implying that we cannot discard a difference of 0 in length outcome, by different delivery method.
In the light of these results, and assuming that this sample was representative of a normally-distributed population, I conclude that for dose levels up to 1mg/day it’s more convenient to deliver Vitamin C through orange juice, though for greater dose levels the difference fades away.
data("ToothGrowth")
library(knitr)
kable(table(ToothGrowth$supp,ToothGrowth$dose),
caption = "Observations by delivery method & dose level",format = "markdown")
library(ggplot2)
plot1 <- ggplot(ToothGrowth,aes(factor(dose),len))
plot1 + geom_boxplot(aes(color=supp)) + labs(x="Dose",y="Length") + theme_bw()