This analysis summarizes the Tooth Growth data set in the datasets package in R. Included in this report is a basic summary of the data and comparisons of supplement delivery method and dosage to tooth length using confidence intervals.
The data is set of 60 observations, length of odontoblasts (teeth) in each of 10 guinea pigs at each of three dose levels of Vitamin C (0.5, 1, and 2 mg) with each of two supplement methods (orange juice or ascorbic acid).
require(ggplot2)
## Loading required package: ggplot2
data(ToothGrowth)
##Summarize the data
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 ...
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
head(ToothGrowth)
The figures seen in this section represent the comparisons of tooth length vs. supplement delivery method and dosage respectively.
##Redefine variables
ToothGrowth$dose<-as.factor(ToothGrowth$dose)
ggplot(data=ToothGrowth,aes(x=dose,y=len))+
geom_boxplot(aes(fill=dose))+
facet_grid(.~supp)+
ggtitle("Tooth Length vs. Dosage by Supplement Method")+
xlab("Dosage")+
ylab("Tooth Length")
ggplot(data=ToothGrowth,aes(x=dose,y=len))+
geom_boxplot(aes(fill=supp))+
facet_grid(.~dose)+
ggtitle("Tooth Length vs. Supplement Method by Dosage")+
xlab("Supplement Method")+
ylab("Tooth Length")
##Compare tooth length to supplement method with 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
From these results, note the p-value is 0.06. Given the p-value of 0.06 is greater than 0.05 and that the confidence interval contains 0, the results show that supplement methods have little to no impact on Tooth growth.
##Compate tooth length to dosage with T test
ToothSub1<-subset(ToothGrowth,ToothGrowth$dose %in% c(1.0,0.5))
t.test(len~dose,data=ToothSub1)
##
## 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
ToothSub2<-subset(ToothGrowth,ToothGrowth$dose %in% c(0.5,2.0))
t.test(len~dose,data=ToothSub2)
##
## 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
ToothSub3<-subset(ToothGrowth,ToothGrowth$dose %in% c(0.5,2.0))
t.test(len~dose,data=ToothSub3)
##
## 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
From these results, note the p-value goes to 0. Since this p-value is basically 0 and the confidence interval does not contain 0, the results show that as dosage increases, tooth length increases. Therefore, dosage does indeed have a positive correlation with tooth growth.
From these results, we can reject the null hypothesis.