Synopsis:

The dataset Tooth Growth provides information on the impact of vitamin C dosage on the tooth growth in guinea pigs. Besides these two variables, there is another variable stored in the dataset holding information about two delivery methods (orange juice vs. ascorbic acid. On the following pages, we will investigate the relationships of these variables.

Preliminaries: Getting an idea about the dataset

First, we load the data Tooth Growth and get some information about the number of observations and variables.

library(ggplot2)
library(gridExtra)
data(ToothGrowth)
str(ToothGrowth)
## '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 ...
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

There are 60 observations and three variables: Tooth length (len), amount of dose of Vitamin C(dose), and the method of delivery (orange juice vs. ascorbic acid) used for injecting the vitamin C into the guinea pigs (supp).

Looking at the distribution of values it gets clear, that the only real interval scaled variable is tooth length. The variable dose may be better interpreted in this case as factor variable, as it has only three values. Thus, it can be alternatively interpreted as ordinally scaled. The variable supp is a nominally scaled as the two values orange juice and ascorbic acid do not dispose of any predefined order nor can they be interpreted numerically.

ToothGrowth$dose <- as.factor(ToothGrowth$dose)
ToothGrowth$supp <- as.factor(ToothGrowth$supp)

There are no NA’s in the dataset; that means, that we can use all the observations in the dataset.

all(colSums(is.na(ToothGrowth)) ==0)
## [1] TRUE

Exploratory analysis

Then, we look at the distribution of the variable tooth growth in relation to the variables dose and delivery method; these density plots already give us an idea about the variation in the data. When doing the t-tests, we’d better assume unequal variances!

i <- qplot(len, data=ToothGrowth, geom="density", fill=dose, alpha=I(0.2))
j <- qplot(len, data=ToothGrowth, geom="density", fill=supp, alpha=I(0.2))
grid.arrange(i, j, ncol=2)

By using the xtabs function, we make a table in order to look at the relationships between the variables. Here, again, we can see how the tooth length varies depending on the size of dosage and the treatment method. One can clearly see that if the dosage is held constant orangejuice leads to a more pronounced tooth growth than ascorbic acid in case of the first two dosage sizes (0.5 mg and 1 mg). However, both delivery mehthods seem to produce more or less the same tooth growth, if the dosage is set at 2 mg! It does not come as surprise, on the other hand, that there is a linear relationship between the size of dosage and tooth growth.

xt <- xtabs(len ~ supp + dose, ToothGrowth)
xt
##     dose
## supp   0.5     1     2
##   OJ 132.3 227.0 260.6
##   VC  79.8 167.7 261.4

Using a coplot from the R documentation of the ToothGrowth dataset, we can illustrate the relationships visually (please note, that I have mentioned the source of this plot deliberately. I do not want any credit for it, neither do I want to be called a cheater! However, as I stumbled upon it, I considered it very useful and easy to create, so I thought about sharing it with some of my peers, that is, with you). Instead of supplying us with the means of each group, there is a circle for each observation, thus telling us something about the distribution within each subgroup. These are important information for deciding, if the descriptive differences we have encountered in the table can be considered as statistically significant. Thus, we move on in our investigation from a mere descriptive discussion of the data to an inferential analysis.

coplot(len ~ dose | supp, data = ToothGrowth, panel = panel.smooth,
       xlab = "ToothGrowth data: length vs dose, given type of supplement")

Looking for significant differences by doing independent t-tests

Next, we run t-tests using tooth length as the outcome variable and dose and supplement method as the predictors. First, the t-tests using the supplement method. Concerning the variations, we use both possibilities of equal and unequal varations:

t.test(ToothGrowth$len ~ ToothGrowth$supp, paired=FALSE, var.equal = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  ToothGrowth$len by ToothGrowth$supp
## t = 1.9153, df = 55.309, p-value = 0.06063
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.1710156  7.5710156
## sample estimates:
## mean in group OJ mean in group VC 
##         20.66333         16.96333

Before investigating the relationship between tooth growth and size of dosage, we have to make subsets, because the variable dose has three values; however, t-tests require predictors with two values.

TG_1 <- subset(ToothGrowth, dose %in% c(0.5,1))
TG_2 <- subset(ToothGrowth, dose %in% c(0.5,2))
TG_3 <- subset(ToothGrowth, dose %in% c(1,2))

t.test(TG_1$len ~ TG_1$dose, paired=FALSE, var.equal = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  TG_1$len by TG_1$dose
## t = -6.4766, df = 37.986, p-value = 1.268e-07
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -11.983781  -6.276219
## sample estimates:
## mean in group 0.5   mean in group 1 
##            10.605            19.735
t.test(TG_2$len ~ TG_2$dose, paired=FALSE, var.equal = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  TG_2$len by TG_2$dose
## t = -11.799, df = 36.883, p-value = 4.398e-14
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -18.15617 -12.83383
## sample estimates:
## mean in group 0.5   mean in group 2 
##            10.605            26.100
t.test(TG_3$len ~ TG_3$dose, paired=FALSE, var.equal = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  TG_3$len by TG_3$dose
## t = -4.9005, df = 37.101, p-value = 1.906e-05
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -8.996481 -3.733519
## sample estimates:
## mean in group 1 mean in group 2 
##          19.735          26.100

Before interpreting the p-values, we have to keep in mind that we are dealing with inferential statistics here. That is, we have to account for the fact, that the more tests one is calculating with a dataset, the more likely it is, that there are seemingly significant results. In such cases, there is the danger to claim a difference between the groups compared, even though in reality there isn’t any (alpha error). So we apply a bonferroni correction that takes the chosen alpha-value as its numerator and the number of tests calculated (in our case that is 8) as its denominator.

bonf <- 0.05 / 8
bonf
## [1] 0.00625

The value bonf(=0.00625) works like a threshold. Any p-value from the t-tests that is smaller than this threshold will be considered significant.

Conclusion

So we can see that the three t-tests calculated on the pairs of dosage sizes all turn out to be significant (p<0.00625[calculated bonferroni p-value]). However, the t-test between the two supplement methods turns out to be non-significant (p=0.06). However, as we have seen before in the coplot, if the dosage is held constant, there appear to be subtantial differences between the two methods at least in the case of dosage sizes of 0.5 mg and 1 mg. This implies that we actually had better applied another statistic that is able to integrate all three variables in one calculation and thus account for dependencies between covariates (e.g. anova, regression analysis). But using one of these statistics was forbidden in the instructions in the assignment. So we stick to our interpretation flagging the differences between dosage sizes as significant and the difference between the two delivery methods as non-significant, while stressing the need for a more thorough investigation of the relationship between the outcome variable tooth growth and the two covariates dosage size and supplementary method.