In Part 1 of this Project, we will analyze the ToothGrowth data in the R datasets package.
# Loading the necessary libraries
library(ggplot2)
# Loading the ToothGrowth data
data("ToothGrowth")
# Converting dose to a factor
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
# Plotting Tooth Length versus Dose Amount by Supplement Delivery Method
ggplot(aes(x=dose, y=len), data=ToothGrowth) + geom_boxplot(aes(fill=dose)) +
xlab("Dose Amount") + ylab("Tooth Length") + facet_grid(~supp) +
ggtitle("Tooth Length vs. Dose Amount by Supplement Delivery Method") +
theme(plot.title = element_text(lineheight=.8, face="bold"))
# Plotting Tooth Length versus Supplement Delivery Method by Dose Amount
ggplot(aes(x=supp, y=len), data=ToothGrowth) + geom_boxplot(aes(fill=supp)) +
xlab("Supplement Delivery Method") + ylab("Tooth Length") + facet_grid(~dose) +
ggtitle("Tooth Length vs. Supplement Delivery Method by Dose Amount") +
theme(plot.title = element_text(lineheight=.8, face="bold"))
# Displaying a summary of the data
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
First, we will compare tooth growth by supplement delivery method using a t-test.
# Comparing tooth growth by supplement delivery method using a t-test
t.test(len~supp,data=ToothGrowth)
##
## 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
The p-value obtained is 0.06. This p-value is greater than the level of significance, alpha = 0.05, and the 95% confidence interval (-0.17, 7.57) contains 0. This suggests that the supplement delivery method may not have a significant impact on tooth growth.
Next, we will compare tooth growth by dose amount using a t-test.
# Comparing tooth growth by dose amounts of 0.5 and 1.0 using a t-test
ToothGrowth_sub <- subset(ToothGrowth, ToothGrowth$dose %in% c(0.5,1.0))
t.test(len~dose,data=ToothGrowth_sub)
##
## 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
# Comparing tooth growth by dose amounts of 0.5 and 2.0 using a t-test
ToothGrowth_sub <- subset(ToothGrowth, ToothGrowth$dose %in% c(0.5,2.0))
t.test(len~dose,data=ToothGrowth_sub)
##
## 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
# Comparing tooth growth by dose amounts of 1.0 and 2.0 using a t-test
ToothGrowth_sub <- subset(ToothGrowth, ToothGrowth$dose %in% c(1.0,2.0))
t.test(len~dose,data=ToothGrowth_sub)
##
## 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
The p-values obtained for all 3 comparisons are essentially 0. The 95% confidence intervals obtained for all 3 comparisons do not contain 0. This suggests that the dose amount has a significant impact on tooth growth, where increasing dose amount increases tooth growth.
Our Assumptions:
Our Conclusions:
From our results shown above, we conclude that the supplement delivery method does not have a significant impact on tooth growth and length. While increasing dose amount increases tooth growth and length.