This reseach gives basic undestanding of Vitamin C effect on teeth growth for guinea pigs based on data collected in the Tooth Growth dataset from the standard R dataset package.
options("scipen"=10)
if (!require(ggplot2)) {
install.packages("ggplot2")
library(ggplot2)
}
if (!require(datasets)) {
install.packages("datasets")
library(datasets)
}
The structure of Tooth Growth dataset is:
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 ...
The dataset contains data for a length of odontoblasts (teeth) for each of 10 guinea pigs broken down by three dose levels of Vitamin C (0.5, 1, and 2 mg) using two feeding approaches: green juice or ascorbic acid.
There are 60 observations with 3 variables.
g <- ggplot(aes(x=dose, y = len), data = ToothGrowth)
g <- g + geom_point(aes(color = supp))
g <- g + theme_bw()
g <- g + labs(x = "Dose", y="Teeth length", title="Guinea teeth length dependecy from Vitamin C ")
g
The shape of distribution density for both types and doses:
g <- ggplot(ToothGrowth, aes(x = len))
g <- g + geom_histogram(aes(y=..density..), colour = "black", fill= "green")
g <- g + geom_density()
g <- g + facet_grid(supp ~ dose)
g <- g + theme_bw()
g <- g + labs(x = "Teeth length", y="Density", title="Teeth length distribution by suppliment type and dose")
g
There are some dependecies visible on the graph:
g <- ggplot(ToothGrowth, aes(x = supp, y = len))
g <- g + geom_boxplot(aes(fill = supp)) + facet_wrap(~ dose)
g <- g + theme_bw()
g <- g + labs(x = "Dose", y="Teeth length", title="Teeth length distribution by suppliment type and dose")
g
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
Each combination of the dose and type of vitamin C should have the same number of samples:
with(ToothGrowth, table(supp, dose))
## dose
## supp 0.5 1 2
## OJ 10 10 10
## VC 10 10 10
Average values of the dose and type of vitamin C are the following:
tapply(ToothGrowth$len, ToothGrowth$dose, mean)
## 0.5 1 2
## 10.605 19.735 26.100
tapply(ToothGrowth$len, ToothGrowth$supp, mean)
## OJ VC
## 20.66333 16.96333
The graphes and summary data analysis could be used to suggest the following hypothesis:
Null hypothesis: Vitamin C type does not have a significant effect on teeth length
t.test(len ~ supp, paired = F, var.equal = F, 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
95% confidence interval includes 0. Even though there are differerent means of differenet Vitamin C type methods on 95% confidence level it does not provide absolute confidence that true difference is not equal to zero. The overall interval is located in area with positive numbers which indicates possible hidden dependecies requiring additional data to be confirmed.
Result: Hypothesis could be true under some conditions.
Null hypothesis: VVitamin C dose increases teeth length for guinea pigs
Reseach the effect of dose for each pair: 0.5 - 1 mg, 1 - 2 mg and 0.5 - 2 mg:
t.test(len ~ dose, paired = F, var.equal = F, data = ToothGrowth[ToothGrowth$dose %in% c(1.0,0.5),])
##
## Welch Two Sample t-test
##
## data: len by dose
## t = -6.4766, df = 37.986, p-value = 0.0000001268
## 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
The means difference does not include 0. Thus,increasing the dose from 0.5 to 1.0 leads to the changes in teeth length.
t.test(len ~ dose, paired = F, var.equal = F, data = ToothGrowth[ToothGrowth$dose %in% c(2.0,1.0),])
##
## Welch Two Sample t-test
##
## data: len by dose
## t = -4.9005, df = 37.101, p-value = 0.00001906
## 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
The means difference does not include 0. Thus,increasing the dose from 1.0 to 2.0 leads to the changes in teeth length.
t.test(len ~ dose, paired = F, var.equal = F, data = ToothGrowth[ToothGrowth$dose %in% c(2.0,0.5),])
##
## Welch Two Sample t-test
##
## data: len by dose
## t = -11.799, df = 36.883, p-value = 0.00000000000004398
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -18.15617 -12.83383
## sample estimates:
## mean in group 0.5 mean in group 2
## 10.605 26.100
The means difference does not include 0. Thus,increasing the dose from 0.5 to 2.0 leads to the changes in teeth length.
Result: More high dose of Vitamin C leads in extensive teeth growth. Hypothesis confirmed.
Provided data in the dataset introduces some links between guinea pigs teeth growth and Vitamin C consumption. During the work with the dataset, two hypothesis were made.
First, Vitamin C type does not have a significant effect on teeth length. Second, Vitamin C dose increases teeth length for guinea pigs. Both hypothesis were confirmed.