Overview
We analyze the ToothGrowth data set by comparing the guinea tooth growth by supplement and dose. 1. Load the ToothGrowth data and perform some basic exploratory data analyses
# load the sample dataset containing ToothGrowth data
library(datasets)
data(ToothGrowth)
library(ggplot2)
# perform data exploratory analysis with summary function
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
d = ToothGrowth
ggplot(d, aes(x=factor(dose), y=len, fill=supp)) +
geom_bar(stat="identity") +
facet_grid(. ~ supp) +
xlab("Dose (mg/day)") +
ylab("Tooth length") +
ggtitle("Inferential Data Analysis on Toothgrowth")
The plots seem to show the basic fact that increasing the dosage of supplements increases the tooth growth.
Hypothesis1: Both supplements are delivering same tooth growth
h1 <- t.test(len ~ supp, data = ToothGrowth)
h1$conf.int
## [1] -0.1710156 7.5710156
## attr(,"conf.level")
## [1] 0.95
h1$p.value
## [1] 0.06063451
The P value is greater than the significance level, we cannot reject the null hypothesis.
Hypothesis2: OJ delivers same tooth growth at low concentration 0.5
h2 <- t.test(len ~ supp, data = subset(ToothGrowth, dose == 0.5))
h2$conf.int
## [1] 1.719057 8.780943
## attr(,"conf.level")
## [1] 0.95
h2$p.value
## [1] 0.006358607
The P value is less than the significance level, the null hypothesis can be rejected. The alternative hypothesis that 0.5 mg/day dosage of OJ delivers more tooth growth than VC is accepted.
Hypothesis3: OJ delivers same tooth growth at low concentration 1
h3 <- t.test(len ~ supp, data = subset(ToothGrowth, dose == 1))
h3$conf.int
## [1] 2.802148 9.057852
## attr(,"conf.level")
## [1] 0.95
h3$p.value
## [1] 0.001038376
The P value is less than the significance level, the null hypothesis can be rejected. The alternative hypothesis that 1 mg/day dosage of OJ delivers more tooth growth than VC is accepted.
Hypothesis4: OJ and VC delivers same tooth growth at low concentration 2
h4 <- t.test(len ~ supp, data = subset(ToothGrowth, dose == 2))
h4$conf.int
## [1] -3.79807 3.63807
## attr(,"conf.level")
## [1] 0.95
h4$p.value
## [1] 0.9638516
The P value is greater than the significance level, the null hypothesis cannot be rejected.
The tooth growth with supplement OJ for lower dosages 0.5 & 1.0 shows higher impact compared to VJ while with high dosage both supplements yield same result.