This prject analyses ToothGrowth data in the R datasets package. It analyses ToothGrowth with regards to type of supplement and amount of dosage and concludes the effect of both on Tooth Growth.
data("ToothGrowth")
summary(ToothGrowth) #displaying a summary of Tooth Growth data
## 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
We will do the hypothesis test in two parts. A> First we will check the effect of supplement type on tooth growth. B> Second we will check the effect of dosage on tooth growth.
H0: The supplement type (VC or OJ) has no effect on Tooth Growth (length)
pval <- round(t.test(len~supp,data=ToothGrowth)$p.value, 2)
confint <- round(t.test(len~supp,data=ToothGrowth)$conf.int,2)
The p-value for the t-test is 0.06 and the confidence interval is (-0.17, 7.57). The p-value is extremely close to the alpha value of 0.05 so we cannot concusively reject the null hypothesis. The confidence intervl has 0 in it so the test is not significant. Hence, we conclude that supplement type (VC or OJ) has no effect on Tooth Growth.
H0: Dosage has no effect on Tooth Growth (Different Doses will have the same effect on Tooth Growth)
#Comparing the toothgrowth for dosages 0.5 and 1
pval_0.5_1 <- round(t.test(ToothGrowth$len[ToothGrowth$dose == 0.5],ToothGrowth$len[ToothGrowth$dose == 1], paired=FALSE)$p.value, 2)
confint_0.5_1 <- round(t.test(ToothGrowth$len[ToothGrowth$dose == 0.5],ToothGrowth$len[ToothGrowth$dose == 1], paired=FALSE)$conf.int, 2)
mean_0.5_1 <- round(t.test(ToothGrowth$len[ToothGrowth$dose == 0.5],ToothGrowth$len[ToothGrowth$dose == 1], paired=FALSE)$estimate, 2)
names(mean_0.5_1) <- c("Mean of 0.5", "Mean of 1")
The p-value of the comparision for dosages 0.5 and 1 is 0 and the confidence interval is (-11.98, -6.28). The p-value is close to 0 so we can reject the null hypothesis. The confidence interval doesn’t contain 0 so our test statistic is significant. So Dosage has an effect on Tooth Growth. We can also see the means for the dosages 0.5 and 1 as 10.61, 19.73 respectively.
Similarly we can run the same analysis for dosages 0.5&2 and 1&2. The results are shown below.
#Comparing the toothgrowth for dosages 0.5 and 2
pval_0.5_2 <- round(t.test(ToothGrowth$len[ToothGrowth$dose == 0.5],ToothGrowth$len[ToothGrowth$dose == 2], paired=FALSE)$p.value, 2)
confint_0.5_2 <- round(t.test(ToothGrowth$len[ToothGrowth$dose == 0.5],ToothGrowth$len[ToothGrowth$dose == 2], paired=FALSE)$conf.int, 2)
mean_0.5_2 <- round(t.test(ToothGrowth$len[ToothGrowth$dose == 0.5],ToothGrowth$len[ToothGrowth$dose == 2], paired=FALSE)$estimate, 2)
names(mean_0.5_2) <- c("Mean of 0.5", "Mean of 2")
The p-value of the comparision for dosages 0.5 and 2 is 0 and the confidence interval is (-18.16, -12.83). The p-value is close to 0 so we can reject the null hypothesis. The confidence interval doesn’t contain 0 so our test statistic is significant.So Dosage has an effect on Tooth Growth. We can also see the means for the dosages 0.5 and 1 as 10.61, 26.1 respectively.
#Comparing the toothgrowth for dosages 0.5 and 1
pval_1_2 <- round(t.test(ToothGrowth$len[ToothGrowth$dose == 1],ToothGrowth$len[ToothGrowth$dose == 2], paired=FALSE)$p.value, 2)
confint_1_2 <- round(t.test(ToothGrowth$len[ToothGrowth$dose == 1],ToothGrowth$len[ToothGrowth$dose == 2], paired=FALSE)$conf.int, 2)
mean_1_2 <- round(t.test(ToothGrowth$len[ToothGrowth$dose == 1],ToothGrowth$len[ToothGrowth$dose == 2], paired=FALSE)$estimate, 2)
names(mean_1_2) <- c("Mean of 1", "Mean of 2")
The p-value of the comparision for dosages 0.5 and 1 is 0 and the confidence interval is (-9, -3.73). The p-value is close to 0 so we can reject the null hypothesis. The confidence interval doesn’t contain 0 so our test statistic is significant.So Dosage has an effect on Tooth Growth. We can also see the means for the dosages 1 and 2 as 19.73, 26.1 respectively.
The conclusions we draw by analysing the Tooth Growth data are the following: 1. The type of supplement i.e. Orange Juice or Vitamin C has no effect on Tooth Growth 2. We see that as the dosage is increased from 0.5 to 1 to 2 our mean estimates increase significantly. Based on the t-tests we can therefore conclude that Dosage has an effect on Tooth Growth. 3. Increase in Dosage is directly proportional to Tooth Growth.