In this project I shall investigate the effect of various doses and delivery methods of vitamin C on the length of guinea pig odontoblasts (cells responsible for tooth growth). Each of sixty guinea pigs 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).
This investigation shall seek to identify whether the different delivery methods and daily dosage levels have significantly different effects on tooth growth.
# Load required software packages.
library(ggplot2)
library(datasets)
# Summarise data
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 ...
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
An initial exploration of the ‘ToothGrowth’ dataset shows 60 observations, each comprising three variables:
The ‘dose’ variable has been stored as a numeric string. This needs to be converted to a factor string so it can be used as a category for further analysis.
# Convert dose variable from number to factor
ToothGrowth$dose<-as.factor(ToothGrowth$dose)
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: Factor w/ 3 levels "0.5","1","2": 1 1 1 1 1 1 1 1 1 1 ...
summary(ToothGrowth)
## len supp dose
## Min. : 4.20 OJ:30 0.5:20
## 1st Qu.:13.07 VC:30 1 :20
## Median :19.25 2 :20
## Mean :18.81
## 3rd Qu.:25.27
## Max. :33.90
# Mean tooth growth by dose - orange juice
ToothGrowth_OJ <-subset(ToothGrowth, supp=="OJ")
len_OJ <- split(ToothGrowth_OJ$len, ToothGrowth_OJ$dose)
sapply(len_OJ, mean)
## 0.5 1 2
## 13.23 22.70 26.06
# Mean tooth growth by dose - ascorbic acid
ToothGrowth_VC <-subset(ToothGrowth, supp=="VC")
len_VC <- split(ToothGrowth_VC$len, ToothGrowth_VC$dose)
sapply(len_VC, mean)
## 0.5 1 2
## 7.98 16.77 26.14
At lower doses (0.5 and 1.0 mg per day), delivery of vitamin C by orange juice appears to have a greater effect on tooth growth than delivery by ascorbic acid. However, at the higher dose of 2.0 mg per day, the results for both orange juice and ascorbic acid appear to be the same.
This is also illustrated by comparing box plots for each dose and delivery method. The box plots show that at the higher dose of 2.0 mg per day, the average results for both orange juice and ascorbic acid appear to be the same, although ascorbic acid has a wider range than orange juice.
# Map results using box plots
ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) + geom_boxplot() + facet_grid(~ supp) + xlab("Dose (mg per day)") + ylab("Tooth growth (length)")
There are two possible factors relating vitamin C to tooth growth:
The significance of each factor will be tested.
# Run t-test to compare delivery methods
# H_0: no significant difference between delivery methods
# H_1: significant difference between delivery methods
t.test(len~supp, 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
Since the p-value is greater than 0.05 and the 95% confidence interval of the test contains zero, it cannot stated with confidence that there is any significant difference between delivery methods in terms of their effect on tooth growth. Therefore, the null hypothesis is not rejected.
# Run t-test to compare 0.5 and 1.0 mg per day
# H_0: no significant difference between 0.5 and 1.0 mg per day
# H_1: significant difference between 0.5 and 1.0 mg per day
t.test(ToothGrowth$len[ToothGrowth$dose == 0.5], ToothGrowth$len[ToothGrowth$dose == 1],
paired = FALSE)
##
## Welch Two Sample t-test
##
## data: ToothGrowth$len[ToothGrowth$dose == 0.5] and ToothGrowth$len[ToothGrowth$dose == 1]
## 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 of x mean of y
## 10.605 19.735
# Run t-test to compare 0.5 and 2.0 mg per day
# H_0: no significant difference between 0.5 and 2.0 mg per day
# H_1: significant difference between 0.5 and 2.0 mg per day
t.test(ToothGrowth$len[ToothGrowth$dose == 0.5], ToothGrowth$len[ToothGrowth$dose == 2],
paired = FALSE)
##
## Welch Two Sample t-test
##
## data: ToothGrowth$len[ToothGrowth$dose == 0.5] and ToothGrowth$len[ToothGrowth$dose == 2]
## t = -11.799, df = 36.883, p-value = 4.398e-14
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -18.15617 -12.83383
## sample estimates:
## mean of x mean of y
## 10.605 26.100
# Run t-test to compare 1.0 and 2.0 mg per day
# H_0: no significant difference between 1.0 and 2.0 mg per day
# H_1: significant difference between 1.0 and 2.0 mg per day
t.test(ToothGrowth$len[ToothGrowth$dose == 1], ToothGrowth$len[ToothGrowth$dose == 2],
paired = FALSE)
##
## Welch Two Sample t-test
##
## data: ToothGrowth$len[ToothGrowth$dose == 1] and ToothGrowth$len[ToothGrowth$dose == 2]
## 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 of x mean of y
## 19.735 26.100
In each of these tests, the p-value is below 0.05, and in fact is very close to zero. None of the 95% confidence intervals include the zero value. On this basis, it can be stated with confidence that:
In all three tests, the null hypothesis is rejected.
Selecting one method or another with which vitamin C is delivered has no significant effect on tooth growth. However, increasing the the amount of vitamin C delivered as a daily dosage does have a significant effect on tooth growth.
# print relevant software and versions
sessionInfo()
## R version 3.5.3 (2019-03-11)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 17763)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=English_United States.1252
## [2] LC_CTYPE=English_United States.1252
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C
## [5] LC_TIME=English_United States.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] ggplot2_3.1.0
##
## loaded via a namespace (and not attached):
## [1] Rcpp_1.0.0 knitr_1.22 magrittr_1.5 tidyselect_0.2.5
## [5] munsell_0.5.0 colorspace_1.4-1 R6_2.4.0 rlang_0.3.1
## [9] stringr_1.4.0 plyr_1.8.4 dplyr_0.8.0.1 tools_3.5.3
## [13] grid_3.5.3 gtable_0.2.0 xfun_0.5 withr_2.1.2
## [17] htmltools_0.3.6 assertthat_0.2.0 yaml_2.2.0 lazyeval_0.2.2
## [21] digest_0.6.18 tibble_2.0.1 crayon_1.3.4 reshape2_1.4.3
## [25] purrr_0.3.1 glue_1.3.1 evaluate_0.13 rmarkdown_1.12
## [29] labeling_0.3 stringi_1.4.3 compiler_3.5.3 pillar_1.3.1
## [33] scales_1.0.0 pkgconfig_2.0.2