In this report, a basic analysis will be given to explore the effects of tooth growth in guinea pigs after receiving one of three dose amounts of vitamin C (0.5, 1.0, or 2.0 mg) via either one of two supplements: orange juice (OJ) or ascorbic acid (VC).
Given that there are six combination categories (3 dose amounts, 2 supplement types), or subgroups, the mean and standard deviation for each of the subgroups are calculated. This information is used to construct a clear and concise graph that describes the data set. The average tooth lengths of each of these subgroups are compared against one another in bars, with the whiskers denoting the standard deviations.
library(datasets)
library(ggplot2)
library(plyr)
groupMean <- ddply(ToothGrowth, .(dose, supp), numcolwise(mean))
groupSd <- ddply(ToothGrowth, .(dose, supp), numcolwise(sd))
limits <- aes(ymax = groupMean$len + groupSd$len, ymin = groupMean$len - groupSd$len)
avoid <- position_dodge(width=0.9)
g <- ggplot(data=groupMean, aes(y=len, x=as.factor(dose), fill=supp))
g <- g + geom_bar(position="dodge", stat="identity")
g <- g + labs(x = "Dosage (mg)", y = "Tooth Length",
title = "Fig 2-1: Average Tooth Length by Dosage and Supplement")
g <- g + geom_bar(position=avoid)
g <- g + geom_errorbar(limits, position=avoid, width=0.4)
g
It appears that for both supplements, the more vitamin C the mouse receives, the longer its tooth will grow. For the dosages of 0.5 mg and 1.0 mg, delivery by orange juice seems to be a more effective method than by ascorbic acid. For the dosage of 2.0 mg, the effects seem to be equal via either delivery method.
A basic set of descriptive statistics for the ToothGrowth data set is as below:
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
Since this is the summary of the entire data set, which contains a mixture of all the six aforementioned subgroups, it is naturally not very informative besides describing the range and distribution of the data set. Seeing the summary statistics of each of the subgroups may be more intuitive:
by(ToothGrowth, list(ToothGrowth$supp, ToothGrowth$dose), summary)
## : OJ
## : 0.5
## len supp dose
## Min. : 8.20 OJ:10 Min. :0.5
## 1st Qu.: 9.70 VC: 0 1st Qu.:0.5
## Median :12.25 Median :0.5
## Mean :13.23 Mean :0.5
## 3rd Qu.:16.18 3rd Qu.:0.5
## Max. :21.50 Max. :0.5
## --------------------------------------------------------
## : VC
## : 0.5
## len supp dose
## Min. : 4.20 OJ: 0 Min. :0.5
## 1st Qu.: 5.95 VC:10 1st Qu.:0.5
## Median : 7.15 Median :0.5
## Mean : 7.98 Mean :0.5
## 3rd Qu.:10.90 3rd Qu.:0.5
## Max. :11.50 Max. :0.5
## --------------------------------------------------------
## : OJ
## : 1
## len supp dose
## Min. :14.50 OJ:10 Min. :1
## 1st Qu.:20.30 VC: 0 1st Qu.:1
## Median :23.45 Median :1
## Mean :22.70 Mean :1
## 3rd Qu.:25.65 3rd Qu.:1
## Max. :27.30 Max. :1
## --------------------------------------------------------
## : VC
## : 1
## len supp dose
## Min. :13.60 OJ: 0 Min. :1
## 1st Qu.:15.28 VC:10 1st Qu.:1
## Median :16.50 Median :1
## Mean :16.77 Mean :1
## 3rd Qu.:17.30 3rd Qu.:1
## Max. :22.50 Max. :1
## --------------------------------------------------------
## : OJ
## : 2
## len supp dose
## Min. :22.40 OJ:10 Min. :2
## 1st Qu.:24.57 VC: 0 1st Qu.:2
## Median :25.95 Median :2
## Mean :26.06 Mean :2
## 3rd Qu.:27.07 3rd Qu.:2
## Max. :30.90 Max. :2
## --------------------------------------------------------
## : VC
## : 2
## len supp dose
## Min. :18.50 OJ: 0 Min. :2
## 1st Qu.:23.38 VC:10 1st Qu.:2
## Median :25.95 Median :2
## Mean :26.14 Mean :2
## 3rd Qu.:28.80 3rd Qu.:2
## Max. :33.90 Max. :2
The six groups are intuitively names as ojHalfGroup, vcHalfGroup, ojOneGroup, vcOneGroup, ojTwoGroup, and vcTwoGroup. Two types of comparisons are made:
ojHalfGroup <- subset(ToothGrowth, supp == 'OJ' & dose == 0.5)$len
vcHalfGroup <- subset(ToothGrowth, supp == 'VC' & dose == 0.5)$len
ojOneGroup <- subset(ToothGrowth, supp == 'OJ' & dose == 1.0)$len
vcOneGroup <- subset(ToothGrowth, supp == 'VC' & dose == 1.0)$len
ojTwoGroup <- subset(ToothGrowth, supp == 'OJ' & dose == 2.0)$len
vcTwoGroup <- subset(ToothGrowth, supp == 'VC' & dose == 2.0)$len
# Comparison of 1.0 mg to 0.5 mg, for OJ
t.test(ojOneGroup, ojHalfGroup, paired=FALSE, var.equal=FALSE)$conf.int
## [1] 5.524366 13.415634
## attr(,"conf.level")
## [1] 0.95
# Comparison of 2.0 mg to 1.0 mg, for OJ
t.test(ojTwoGroup, ojOneGroup, paired=FALSE, var.equal=FALSE)$conf.int
## [1] 0.1885575 6.5314425
## attr(,"conf.level")
## [1] 0.95
# Comparison of 1.0 mg to 0.5 mg, for VC
t.test(vcOneGroup, vcHalfGroup, paired=FALSE, var.equal=FALSE)$conf.int
## [1] 6.314288 11.265712
## attr(,"conf.level")
## [1] 0.95
# Comparison of 2.0 mg to 1.0 mg, for VC
t.test(vcTwoGroup, vcOneGroup, paired=FALSE, var.equal=FALSE)$conf.int
## [1] 5.685733 13.054267
## attr(,"conf.level")
## [1] 0.95
# Comparison of OJ to VC, for dose = 0.5 mg
t.test(ojHalfGroup, vcHalfGroup, paired=FALSE, var.equal=FALSE)$conf.int
## [1] 1.719057 8.780943
## attr(,"conf.level")
## [1] 0.95
# Comparison of OJ to VC, for dose = 1.0 mg
t.test(ojOneGroup, vcOneGroup, paired=FALSE, var.equal=FALSE)$conf.int
## [1] 2.802148 9.057852
## attr(,"conf.level")
## [1] 0.95
# Comparison of OJ to VC, for dose = 2.0 mg
t.test(ojTwoGroup, vcTwoGroup, paired=FALSE, var.equal=FALSE)$conf.int
## [1] -3.79807 3.63807
## attr(,"conf.level")
## [1] 0.95
The assumption is made that all the subgroups are independent and not treated as pairs in any of these comparisons, since we have no evidence that an animal has received multiple supplements or multiple dosages. Also, we assume unequal population variance of tooth length for any of the comparisons made, since we do not have further relevant information on that.
For the comparison of dosages, we can see that the 95% confidence interval lies completely above zero in each and every of these comparisons. This implies that doubling dose amounts does have a positive effect on tooth growth at these dosages for either supplement. No T-tests are necessary for validating that the effect of the increase in dosage from 0.5 mg to 2.0 mg is significant, since smaller increases in dosage from 0.5 mg to 1.0 mg, and from 1.0 mg to 2.0 mg, both have been already shown to have a notable effect on tooth growth for either supplement.
For the comparison of supplements, in case of the dose amounts of 0.5 mg and 1.0 mg, the 95% confidence interval lies completely above zero. This implies that orange juice is a more effective delivery method at these dosages. However, when the dose amount is 2.0 mg, the confidence interval not only includes zero, but is almost centered about zero. This implies that it is hard to prove that either supplement is more effective than the other in helping tooth growth when it is used to deliver 2.0 mg of vitamin C to the animals.