ToothGrowth data analysis

Load data and packages

data("ToothGrowth")
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.2.3
library(lattice)
library(dplyr)
## 
## Attaching package: 'dplyr'
## 
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## 
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Exploratory data analysis

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 ...

ToothGrowth is a data frame with 60 observations on 3 variables recording the response of odontoblasts growth in each of 10 guinea pigs at each of three dose levels of Vitamin C with each of two delivery methods: orange juice and ascorbic acid.

ggplot(ToothGrowth, aes(supp, len)) +
  geom_bar(stat = "identity", aes(fill = dose)) +
  labs(title = "Comparison between supplements for different doses", y = "Teeth Lenth", x = "")

xyplot(len~dose|supp, data = ToothGrowth, main = "Scatterplots by Supplements and Dose", xlab = "Dose (mg)", ylab = "Teeth Length")

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
boxplot(len~dose*supp, data = ToothGrowth, main = "Boxplot by Supplement types and doses", xlab = "Supplement types and doses", ylab = "Teeth Length")

Confidence Interval & Hypothesis test

To quantify uncertainty of estimates about the impact of supplements and doses on the length of odontoblasts, t test is performed for each hypothesis.

Hypothesis 1: Given dose equals to 1.0mg, Vitamin C delivered from orange juice has larger impact on the length of odontoblasts than ascorbic acid does.

t.test(len~supp, data = ToothGrowth[ToothGrowth$dose==1.0,])
## 
##  Welch Two Sample t-test
## 
## data:  len by supp
## t = 4.0328, df = 15.358, p-value = 0.001038
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  2.802148 9.057852
## sample estimates:
## mean in group OJ mean in group VC 
##            22.70            16.77

The confidence interval does not contain 0. P value is less than 0.05. So the null hypothesis is rejected. Hypothesis 1 is failed to rejected.

Hypothesis 2: Given dose equals to 2.0mg, Vitamin C delivered from orange juice has larger impact on the length of odontoblasts than ascorbic acid does.

t.test(len~supp, data = ToothGrowth[ToothGrowth$dose==2.0,])
## 
##  Welch Two Sample t-test
## 
## data:  len by supp
## t = -0.046136, df = 14.04, p-value = 0.9639
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -3.79807  3.63807
## sample estimates:
## mean in group OJ mean in group VC 
##            26.06            26.14

The confidence interval spans 0. P value larger than 0.05 indicates a lack of evidence to reject the null hypothesis. So hypothesis 2 is rejected.

As the dose increases from 1.0mg to 2.0mg, the relative advantage of orange juice to ascorbic acid deminishes.

Hypothesis 3: For Vitamin C delivered from orange juice, larger the dose, higher the impact on odontoblasts length.

oj <- ToothGrowth[ToothGrowth$supp=="OJ",]
t.test(len~dose, data = oj[oj$dose!=1.0,])
## 
##  Welch Two Sample t-test
## 
## data:  len by dose
## t = -7.817, df = 14.668, p-value = 1.324e-06
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -16.335241  -9.324759
## sample estimates:
## mean in group 0.5   mean in group 2 
##             13.23             26.06

The confidence interval does not span 0. P value is smaller than 0.05. So the null hypothesis is rejected. Hypothesis 1 is failed to rejected. Larger amount of ascortic acid contributes more on the growth of odontoblasts.

Hypothesis 4: For Vitamin C delivered in the form of ascorbic acid, larger the dose, higher the impact on odontoblasts length.

vc <- ToothGrowth[ToothGrowth$supp=="VC",]
t.test(len~dose, data = vc[vc$dose!=1.0,])
## 
##  Welch Two Sample t-test
## 
## data:  len by dose
## t = -10.388, df = 14.327, p-value = 4.682e-08
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -21.90151 -14.41849
## sample estimates:
## mean in group 0.5   mean in group 2 
##              7.98             26.14

0 is not contained in confidence interval. P value is lower than 0.05. So the null hypothesis is rejected. Hypothesis 1 is failed to rejected. Larger amount of Vitamin C contribute more on the growth of odontoblasts.

Conclusion

  1. At lower dose level, ascortic acid works more efficiently than Vitamin C does. When the dose reaches 2.0mg, the relative advantage of ascortic acid vanishes.
  2. For both types of supplements, impact increases with the dose.