Objective

Here, we explore the Toothgrowth data in the R datasets package and perform inferential analysis of the data using statistical tools like confidence interval and hypothesis testing.

About the data

The ToothGrowth data comprises the effect of vitamin C on tooth growth in Guinea pigs. The len column is the length of odontoblasts (cells responsible for tooth growth) in 60 guinea pigs. The dose column denotes the dose levels of vitamin C (0.5, 1, and 2 mg/day) and the supp column denote the delivery methods, orange juice (coded OJ) or ascorbic acid (a form of vitamin C and coded as VC).

Preliminary exploration

As a first step, we do preliminary exploration to understand the data both qualitatively and quantitatively.

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 ...
sum(is.na(ToothGrowth))
## [1] 0
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
# No of observations for each of the three doses, namely, 0.5, 1.0, and 2.0 mg/day
sapply(c(0.5,1.0,2.0),function(i) 
      length(ToothGrowth[ToothGrowth$dose %in% i,1])) 
## [1] 20 20 20

We see that the data is clean and ready for analysis. Each of the three doses contain 20 observations with 10 for OJ and 10 for VC. There are a few basic questions that we need to ask regarding this data; (i) is there a linear relationship between dose and length? (ii) does a specific delivary method has more impact in length than the other? (iii) does the impact of delivary method vary with varying dose?

Let us visualize the data to understand the data based on the above questions.

p1 <- ggplot(data = ToothGrowth, aes(x = factor(dose), y = len)) + 
        geom_boxplot() + geom_point()
p2 <- ggplot(data = ToothGrowth, aes(x = supp, y = len)) + 
        geom_boxplot() + geom_point()
grid.arrange(p1,p2,ncol=2)
Boxplot on the left compares the effect of dosage levels with the length. On the right, the impact of the two delivery methods and length is plotted.

Boxplot on the left compares the effect of dosage levels with the length. On the right, the impact of the two delivery methods and length is plotted.

Let us visualize the impact of the delivery methods for all the dosage levels to that of the length.

ggplot(data = ToothGrowth, aes(x = supp, y = len)) +
        geom_boxplot(aes(fill = factor(dose))) + facet_wrap(~ dose)
Boxplot examines the effect of delivery method for each dosage level to that of the length.

Boxplot examines the effect of delivery method for each dosage level to that of the length.

Based on Fig. 1, we can form two hypotheses, which we will test with confidence intervals and hypothesis testing:

  1. As we increase the dose, the length of the odontoblasts increase (\(H_a: \mu_{l_{0.5}} - \mu_{l_{1}} < 0\)).
  2. The delivery method OJ seems to be more effective than VC (\(H_a: \mu_{OJ}-\mu_{VC} > 0\)).

Inspecting Fig. 2, there seems to be a difference in effect in delivery method in impacting the length for dose levels 0.5 and 1 mg/day, but not for dose level 2 mg/day. We are not going to form any hypothesis with regard to this aspect.

Hypothesis testing

Effect of dose on length

Analysis of variance (ANOVA) can be used to test hypothesis for 3 or more samples, but we are going to limit our analysis to methods that were taught in this course. So, first let us subset the toothgrowth data into two sets (1. Doses 0.5 and 1 mg/day as one set, and 2. Doses 1 and 2 mg/day as another set) and perform two sample T test [t-test()].

Our hypothesis:
Null, \(H_0: \mu_{l_{0.5}} - \mu_{l_{1}} = 0\)
Alternative, \(H_a: \mu_{l_{0.5}} - \mu_{l_{1}} < 0\)

subset_d1 <- arrange(subset(ToothGrowth, dose %in% c(0.5, 1.0)),desc(dose))
subset_d2 <- arrange(subset(ToothGrowth, dose %in% c(1.0, 2.0)),desc(dose))
t.test(data = subset_d1, len~dose, paired = F, var.equal = F, alternative = "less")
## 
##  Welch Two Sample t-test
## 
## data:  len by dose
## t = -6.4766, df = 37.986, p-value = 6.342e-08
## alternative hypothesis: true difference in means is less than 0
## 95 percent confidence interval:
##       -Inf -6.753323
## sample estimates:
## mean in group 0.5   mean in group 1 
##            10.605            19.735

We see that there is very strong evidence (p-value = 6.342e-08) in favor of the alternative hypothesis that the true difference in mean is less than 0 for doses 0.5 and 1 mg/day. The 95% CI of the difference in mean is (-Inf, -6.753).

The same test performed for subset_d2, which contains the information for doses 1 and 2 mg/day.

Our hypothesis:
Null, \(H_0: \mu_{l_{1}} - \mu_{l_{2}} = 0\)
Alternative, \(H_a: \mu_{l_{1}} - \mu_{l_{2}} < 0\)

t.test(data = subset_d2, len~dose, paired = F, var.equal = F, alternative = "less")
## 
##  Welch Two Sample t-test
## 
## data:  len by dose
## t = -4.9005, df = 37.101, p-value = 9.532e-06
## alternative hypothesis: true difference in means is less than 0
## 95 percent confidence interval:
##      -Inf -4.17387
## sample estimates:
## mean in group 1 mean in group 2 
##          19.735          26.100

Again, we see that there is very strong evidence (p-value = 9.532e-06) in favor of the alternative hypothesis that the true difference in mean is less than 0 for doses 1 and 2 mg/day. The 95% CI of the difference in mean is (-Inf, -4.17387).

Effect of delivery method on length

We perform the two-sample t-test to test the efficacy of delivery method on the length of odontoblasts.

Our hypothesis:
Null, \(H_a: \mu_{OJ}-\mu_{VC} = 0\)
Alternative, \(H_a: \mu_{OJ}-\mu_{VC} > 0\)

t.test(data = ToothGrowth, len~supp, paired = F, var.equal = F, alternative = "greater")
## 
##  Welch Two Sample t-test
## 
## data:  len by supp
## t = 1.9153, df = 55.309, p-value = 0.03032
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  0.4682687       Inf
## sample estimates:
## mean in group OJ mean in group VC 
##         20.66333         16.96333

We see that there is strong evidence (p-value = 0.0303) in favor of the alternative hypothesis that the true difference in mean is greater than 0 for supp OJ compared to VC delivery method in impacting the length. The 95% CI of the difference in mean is (0.4683, Inf).

Conclusion

Let me briefly state the assumptions that were made for this analysis. The description in ToothGrowth dataset states 60 guinea pigs were used in the study to perform 60 measurements of length variable. Thus we assume idenependence of measurements. It is also assumed that the experiment is randomized. For each group of data, the variance is assumed to be unequal, which is also partially supported by the boxplots.

Based on the results of the hypotheses testing, we conclude that

  1. there is a positive linear relationship between the dose level and the length of the odontoblasts, and
  2. the OJ delivery method is more effective than the VC method.