Overview

In this section of the Statistical Inference Course Project, I analyze the ToothGrowth data set in R, using hypothesis testing to discern the influence of supplement and dose on tooth length.

Data summary

The ToothGrowth data set consists of 60 rows in 3 columns. The first column contains data on tooth length. The second is the supplement given, either OJ or VC, and the third is the dose of supplement given, either 0.5, 1, or 2.

ToothGrowth$dose <- as.factor(ToothGrowth$dose)
hist(ToothGrowth$len, xlab = "Tooth length", main = "Histogram of tooth length")

summary(ToothGrowth)
##       len        supp     dose   
##  Min.   : 4.20   OJ:30   0.5:20  
##  1st Qu.:13.07   VC:30   1  :20  
##  Median :19.25           2  :20  
##  Mean   :18.81                   
##  3rd Qu.:25.27                   
##  Max.   :33.90

Tooth length for all groups is multimodal with a leftward skewed distribution. The mean tooth length is 18.8133333 with standard deviation of 7.6493152. However, a boxplot shows a possible difference between tooth lengths between supplements.

boxplot(len~supp, ToothGrowth)

meanlen <- ToothGrowth %>% group_by(supp) %>% summarize(mean(len, na.rm = TRUE))
meanlen

Mean tooth length appears to be higher among the OJ supplemental group, with a mean of 20.7 versus 17.0 in the VC group. Similarly, differences appear between dosage, with mean tooth length increasing as dose increases.

boxplot(len~dose, ToothGrowth)

doselen <- ToothGrowth %>% group_by(dose) %>% summarize(mean(len, na.rm = TRUE))
doselen

Hypothesis

For this analysis, I use the t.test function in R with an alpha of 0.05. I use Welch two-sample t-tests as the variation in the boxplots appears to differ between groups. I first test the hypothesis that the mean tooth length between the OJ and VC groups are the same using a two-sided t-test. I then test the same hypothesis between the three dose groups with two-sided t-tests, using the Bonferroni method in the p.adjust function to control for multiple comparisons.

Results

Supplements

t.test(len~supp, ToothGrowth, alternative = c("two.sided"))
## 
##  Welch Two Sample t-test
## 
## data:  len by 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

I fail to reject the null hypothesis that the true difference in means between the supplement groups is equal to zero. With a p-value of 0.061, the difference between the means fails to reach the 0.05 level.

Dose

Dose0.5_1 <- subset(ToothGrowth, dose == 0.5 | dose == 1)
Dose0.5_2 <- subset(ToothGrowth, dose == 0.5 | dose == 2)
Dose1_2 <- subset(ToothGrowth, dose == 1 | dose == 2)
dose1 <- t.test(len~dose, Dose0.5_1, alternative = c("two.sided"))
dose1
## 
##  Welch Two Sample t-test
## 
## data:  len by 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
dose2 <- t.test(len~dose, Dose0.5_2, alternative = c("two.sided"))
dose2
## 
##  Welch Two Sample t-test
## 
## data:  len by 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
dose3 <- t.test(len~dose, Dose1_2, alternative = c("two.sided"))
dose3
## 
##  Welch Two Sample t-test
## 
## data:  len by 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
p_values <- c(dose1$p.value, dose2$p.value, dose3$p.value)
adjusted_p <- p.adjust(p_values, method = c("bonferroni"))
adjusted_p
## [1] 3.804902e-07 1.319257e-13 5.719289e-05

Tooth length differed significantly among dose groups, with tooth length in the 2 group significantly greater than either 1 or 0.5 (adjusted p-values = 5.7192885^{-5} and 1.3192575^{-13}) and tooth length in the 1 group significantly greater than in the 0.5 group (adjusted p-value = 3.8049022^{-7}). All p-values were lower than alpha = 0.05

Conclusions

I conclude that mean tooth length did not significantly differ between supplements. This failure to reject the null hypothesis appears to be more due to low power than an actual lack of difference, as the p-value for the difference between means was nearly statistically significant (p = 0.061) despite the fact the treatment groups were small (n = 30 per treatment).

However, it appears that the dose of the supplements did make a statistically significant difference in tooth length, even with treatment group sizes of only 20, as all three p-values were still much lower than the cut-off value of p = 0.05 even after correcting for multiple comparisons.

The only assumption made during this analysis was that the data was approximately normal for each group. This appears reasonable as the median in close to the centers of each boxplot. A more thorough analysis would include a Shapiro-Wilks test for normalacy as well as an ANOVA test with interaction terms between dose and supplement followed by a Tukey HSD post-hoc test if significant.