1- Provide a basic summary of the data.
2- Use confidence intervals and/or hypothesis tests to compare tooth growth by supp and dose.
3- State your conclusions and the assumptions needed for your conclusions.
So, lets load and summarize the thooth growth data:
data(ToothGrowth)
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)
## len supp dose
## 1 4.2 VC 0.5
## 2 11.5 VC 0.5
## 3 7.3 VC 0.5
## 4 5.8 VC 0.5
## 5 6.4 VC 0.5
## 6 10.0 VC 0.5
plot <- ggplot(ToothGrowth,
aes(x=factor(dose),y=len,fill=factor(dose)))
plot + geom_boxplot(notch=F) + facet_grid(.~supp) +
scale_x_discrete("Dosage") +
scale_y_continuous("Length of Teeth") +
ggtitle("Effect of Dosage and Supplement on Tooth Growth")
supp.t1 <- t.test(len~supp, paired=F, var.equal=T, data=ToothGrowth)
supp.t2 <- t.test(len~supp, paired=F, var.equal=F, data=ToothGrowth)
supp.result <- data.frame("p-value"=c(supp.t1$p.value, supp.t2$p.value),
"Conf-Low"=c(supp.t1$conf[1],supp.t2$conf[1]),
"Conf-High"=c(supp.t1$conf[2],supp.t2$conf[2]),
row.names=c("Equal Var","Unequal Var"))
supp.result
## p.value Conf.Low Conf.High
## Equal Var 0.06039337 -0.1670064 7.567006
## Unequal Var 0.06063451 -0.1710156 7.571016
The supplement (OJ) appears to provide better results than the supplementing with VC.
Part1 & 2 all on [github]https://github.com/aabodabash/BasicInferenceAnalysis.git