We analyse the Tootgrowth dataset where the length of teeth of 10 ten guinea pigs is studied against 3 diffent dosage levels of vitamin C and two different delivery methods. While the quantity of vitamin C seems to have a positive effect on tooth growth, the same cannot be said for the delivery method.
library(datasets)
data("ToothGrowth")
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
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 ...
The dataset is a three-column dataset containing the length of teeth (column ‘len’) in 10 guinea pigs at each of 3 dose levels (column ‘dose’) of Vitamin C (0.5,1,2 mg) and with each of two delivery methods (column ‘supp’). The latter is a factor variable whereas the other two are numeric.
The first thing we want to have an indea about is the influence of the delivery method, regardless of the dose, on tooth length
From the box plot we see that the orange juice seems to be related to longer teeth. The second thing we are interested in is to see the relation between tooth length and vitamin dose regardless of the delivery method
Finally, the third thing we want to check is if the delivery method seems to have the same impact at every dosage levels
The data suggests therefore the amount of Vitamin C taken by each pig to be directly proportional to their tooth length.
From a first exploration we see that a reasonable hypothesis is that the orange juice is a more effective method to deliver Vitamin C and to foster teeth growth at least at lower dosage levels (i.e. below 2). We now proceed to a more rigourous analysis of this hypothesis
The first thing we want to check is if the observed difference between the average tooth length associated to vitamin C and to the ascorbic acid is consisten with zero within a 95% confidence interval. In other words we want to be reasonably confident that the observed difference is not a statistical fluctuation. In order to do this we perform a 2-sample t-test after subsetting the data according to the delivery method. Even though it seems from the dataset description that the same 10 pigs have received the different dosages of vitamine C via both delivery methods, we are not given their identity and therefore can only consider the group averages rather than averages over indiduals. For this reason we choose to use an independent sample test but we are still allowed to assume equal variance between the groups.
sample1=ToothGrowth[ToothGrowth$supp %in% "VC",]
sample2=ToothGrowth[ToothGrowth$supp %in% "OJ",]
t.test(sample1$len,sample2$len,alt="two.sided",paired=FALSE,var.equal=TRUE,conf.int=0.95)
##
## Two Sample t-test
##
## data: sample1$len and sample2$len
## t = -1.9153, df = 58, p-value = 0.06039
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -7.5670064 0.1670064
## sample estimates:
## mean of x mean of y
## 16.96333 20.66333
From the test we see that, at 95% confidence level, the observed difference in averages is compatible with zero, and therefore we cannot reject the null hypothesis according to which the delivery method has no effect over tooth length.
We now proceed to estimate the influence of the vitamin C dose on tooth length:
sample1=ToothGrowth[ToothGrowth$dose == 0.5,]
sample2=ToothGrowth[ToothGrowth$dose == 1.0,]
sample3=ToothGrowth[ToothGrowth$dose == 2.0,]
t.test(sample1$len,sample2$len,alt="two.sided",paired=FALSE,var.equal=TRUE,conf.int=0.95)
##
## Two Sample t-test
##
## data: sample1$len and sample2$len
## t = -6.4766, df = 38, p-value = 1.266e-07
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -11.983748 -6.276252
## sample estimates:
## mean of x mean of y
## 10.605 19.735
t.test(sample2$len,sample3$len,alt="two.sided",paired=FALSE,var.equal=TRUE,conf.int=0.95)
##
## Two Sample t-test
##
## data: sample2$len and sample3$len
## t = -4.9005, df = 38, p-value = 1.811e-05
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -8.994387 -3.735613
## sample estimates:
## mean of x mean of y
## 19.735 26.100
Both ttests show that the difference in average tootlength between two consecutive level of dosage group have a vanishing probability of belonging to a distribution centered at zero and that the confidence interval do not contain zero. This allow us to reject, at 95% confidence level, the null hypothesis i.e. that vitamin C dosage has no effect on tooth length.
In conclusion, whereas we can be reasonably confident that Vitamin C has a positive effect on tooth lenght, we cannot be equally confident in assessing that the delivery method is somewhat important and therefore more data should perhaps be collected to answer this question. We reached those conclusions based on a 95% confidence t.test, assuming independent samples and equal variances.