Now in the second portion of the project, we’re going to analyze the ToothGrowth data in the R datasets package.
Load the ToothGrowth data and perform some basic exploratory data analyses Provide a basic summary of the data. Use confidence intervals and/or hypothesis tests to compare tooth growth by supp and dose. (Only use the techniques from class, even if there’s other approaches worth considering) State your conclusions and the assumptions needed for your conclusions.
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
plot(ToothGrowth$supp,ToothGrowth$len, ylab="Length of Tooth",
main="Tooth Growth of Guinea Pig: O.J. vs Vitamin C")
We see that there is a difference in the mean of OJ vs VC. I would like to test if the mean of Toothgrowth for OJ is greater than the mean Toothgrowth of VC. We would use a one sided student t test.
##
## Welch Two Sample t-test
##
## data: OJ$len and VC$len
## 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 of x mean of y
## 20.66333 16.96333
From the output we also get the 95 percent confidence interval, which is [0.468, infinity]. This does not contain 0, so we should reject the null hypothesis and conclude the alternative hypothesis.
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, data=ToothGrowth, notch=TRUE,
main="Tooth Growth", xlab="Dose")
Dose0.5<-subset(ToothGrowth, dose==0.5)
Dose2<-subset(ToothGrowth, dose==2)
t.test(Dose2$len, Dose0.5$len, paired=FALSE, var.equal = FALSE, alternative=c("greater"), conf.level = 0.975)
##
## Welch Two Sample t-test
##
## data: Dose2$len and Dose0.5$len
## t = 11.799, df = 36.883, p-value = 2.199e-14
## alternative hypothesis: true difference in means is greater than 0
## 97.5 percent confidence interval:
## 12.83383 Inf
## sample estimates:
## mean of x mean of y
## 26.100 10.605
When comparing the dose level of 2 to dose level 0.5, we find that dose 2 is statistical sigificantly greater than dose 0.5 for tooth growth at alpha 0.025 level.