The response in ToothGrowth dataset is the length of odontoblasts (cells responsible for tooth growth) in 60 guinea pigs. Each animal received one of three dose levels of vitamin C (0.5, 1, and 2 mg/day) by one of two delivery methods, orange juice or ascorbic acid.
The project aims to analyse ToothGrowth dataset in R datasets package and use relevant tests to compare tooth growth by supplement and dose
library(knitr)
library(ggplot2)
library(datasets)
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 ...
names(ToothGrowth) <- c("Length", "Supplement", "Dose")
levels(ToothGrowth$Supplement) <- c("Orange Juice", "Ascorbic Acid")
ToothGrowth$Dose <- as.factor(ToothGrowth$Dose)
str(ToothGrowth)
## 'data.frame': 60 obs. of 3 variables:
## $ Length : num 4.2 11.5 7.3 5.8 6.4 10 11.2 11.2 5.2 7 ...
## $ Supplement: Factor w/ 2 levels "Orange Juice",..: 2 2 2 2 2 2 2 2 2 2 ...
## $ Dose : Factor w/ 3 levels "0.5","1","2": 1 1 1 1 1 1 1 1 1 1 ...
ggplot(data = ToothGrowth) +
geom_boxplot(aes(x = Dose,y = Length,fill = Supplement),
show.legend = F) +
facet_grid(.~Supplement) +
labs(title = "Tooth Length by dosage of each type of supplement")
Boxplot clearly shows a higher tooth growth when supplemented with Orange Juice with doses of 0.5 and 1 mg/day, but growth is nearly same for both supplements with a dose of 2 mg/day.
Null Hypothesis, \(H_0\) : No difference in tooth growth supplemented by Orance Juice and Ascorbic Acid
Alternative Hypothesis, \(H_1\) : Orance Juice is better on tooth growth than Ascorbic Acid
t1 <- t.test(Length~Supplement,data=ToothGrowth); t1
##
## Welch Two Sample t-test
##
## data: Length by Supplement
## 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 Orange Juice mean in group Ascorbic Acid
## 20.66333 16.96333
95% confidence interval lies between -0.171 and 7.571 which includes zero. Hence it is not significant. p-value of the test is 0.06063 which is higher than 5% significance level. Hence, we canโt reject the null hypothesis and conclude that there is no difference in tooth growth caused by both supplements.
ggplot(data = ToothGrowth) +
geom_boxplot(aes(x = Supplement,y = Length,fill = Dose),
show.legend = F) +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
facet_grid(.~Dose) +
labs(title = "Tooth Length by supplement of each amount of dose")
Boxplot clearly shows a higher tooth growth higher dose of supplement. We will test hypothesis if amount of dose is significant by testing each pair of dose amount.
Null Hypothesis, \(H_0\) : No difference in tooth growth between supplements of dose 0.5 and 1 mg/day
Alternative Hypothesis, \(H_1\) : 1 mg/day dose is more effective for higher tooth growth than dose of 0.5 mg/day
t2 <- t.test(Length~Dose,data = subset(ToothGrowth,
ToothGrowth$Dose %in% c(1.0,0.5)));t2
##
## Welch Two Sample t-test
##
## data: Length 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
p-value of 1.268300710^{-7} is very small. Hence, we can confidently reject the null hypothesis and conclude that a dose 1mg/day is more effective for tooth growth than 0.5mg/day.
Null Hypothesis, \(H_0\) : No difference in tooth growth between supplements of dose 2 and 1 mg/day
Alternative Hypothesis, \(H_1\) : 2 mg/day dose is more effective for higher tooth growth than dose of 1 mg/day
t3 <- t.test(Length~Dose,data = subset(ToothGrowth,
ToothGrowth$Dose %in% c(2.0,1.0)));t3
##
## Welch Two Sample t-test
##
## data: Length by Dose
## t = -4.9005, df = 37.101, p-value = 1.906e-05
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -8.996481 -3.733519
## sample estimates:
## mean in group 1 mean in group 2
## 19.735 26.100
p-value of 1.906429510^{-5} is very small. Hence, we can confidently reject the null hypothesis and conclude that a dose 2 mg/day is more effective for tooth growth than 1 mg/day.
We can conclude from the analysis that supplement type has no effect on tooth growth, and increasing the dose level leads to increased tooth growth.
Assumptions