In the this report we aim to investigate tooth growth data in the R datasets package. We will perform some basic exploratory analyses on the dataset to get a summary of the data. We will also be using confidence intervals and/or hypothesis tests to compare tooth growth by supp and dose.
The response 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 (a form of vitamin C and coded as VC).
Format
A data frame with 60 observations on 3 variables.
data("ToothGrowth")
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
dim(ToothGrowth)#dimension of the dataset
## [1] 60 3
Here we can see few rows of the data set which comprises of length, supplement, and dosage. The dimension of the data set is 60, 3. To get more insight from the data, we grouped the data by supplement and dosage, which will show mean in each group.
total.growth <- ToothGrowth %>% group_by(supp,dose) %>% summarize(mean.growth = mean(len))
total.growth
## # A tibble: 6 x 3
## # Groups: supp [2]
## supp dose mean.growth
## <fct> <dbl> <dbl>
## 1 OJ 0.5 13.2
## 2 OJ 1 22.7
## 3 OJ 2 26.1
## 4 VC 0.5 7.98
## 5 VC 1 16.8
## 6 VC 2 26.1
g <- ggplot(total.growth , aes(x = dose, y = mean.growth , colour = supp))
g <- g + geom_line(size = 2)
g <- g + labs(title = "Total growth(in means) by supplement and dosage" , x = "Dosage(mg/day)" , y = "Total Growth(mean)")
print(g)
From the above line graph we can infer that the VC gives less growth in average as compare to the OJ supplement for dosages 0.5 mg/day and 1 mg/day but in case of 2 mg/day both the supplement has the same mean in the growth of length. By this analyses we can assume that if the dosage is 2 mg/day both will give approximately same results but for the other dosages OJ is comparatively more effective.
H0 - Supplement OJ is better than VC in terms of growth in the length and different types of the dosages.
Ha - Growth depends on the dosage solely irrespective of the type of supplement
Checking for the null hypothesis
#using T-test to get the confidence interval and p-value
t.test(len~supp, paired = FALSE, data = ToothGrowth)
##
## Welch Two Sample t-test
##
## data: len by supp
## 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 OJ mean in group VC
## 20.66333 16.96333
Here we can see the confidence interval contains zero and p-value is greater than 0.5(i.e. significance level) which means this test does not give enough evidence to prove that our null hypothesis is true. Therefore we need to further investigate.
#Checking for the dose 0.5 and 1
doselessthan2 <- ToothGrowth %>% filter(dose <= 1)
t.test(len~dose, paired = FALSE, data = doselessthan2)$conf
## [1] -11.983781 -6.276219
## attr(,"conf.level")
## [1] 0.95
dosegreaterthan1 <- ToothGrowth %>% filter(dose >= 1)
t.test(len~dose, paired = FALSE, data = dosegreaterthan1)$conf
## [1] -8.996481 -3.733519
## attr(,"conf.level")
## [1] 0.95
Here we are checking for the dose 0.5 and 1, we can observe that the confidence interval is in negative and it does not contain zero, therefore we can say that with the increase in the dosage from 0.5 to 1, the mean in the growth has increased. We also got the same result if we checked for the dosage 1 and 2.
#Trying to get which of the supplement is better
#Filtering the data to get the data only with dosage = 2
dosage.2 <- ToothGrowth %>% filter(dose == 2)
t.test(len ~ supp, paired = FALSE, data = dosage.2)$conf.int
## [1] -3.79807 3.63807
## attr(,"conf.level")
## [1] 0.95
#For dosage less than 2
t.test(len~supp, paired = FALSE, data = doselessthan2)$conf
## [1] 1.875234 9.304766
## attr(,"conf.level")
## [1] 0.95
From the above tests we are basically trying to achieve that whether we can infer which of the supplement is better if we exclude the dosage which is equal to 2.
From the analyses we can infer that we can reject our null hypothesis and conclude that irrespective of the type of the supplement if we increase the dosage, the size of the tooth will increase accordingly. But we also further investigated the data which tells us that we we exclude the dosage quantity 2 mg/day, we can firmly say that Orange Juice(OJ) is a better supplement compared to the VC.