This portion of the Statistical Inference class project gives some preliminary analysis of a data set collected in a study of the effect of Vitamin C on tooth growth in guinea pigs.
data <- as.data.frame(ToothGrowth)
str(data)
## '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 ...
head(data, n = 5)
## 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
Preliminary visualization indicates that odontoblasts may be longer when the vitamin C is administered with orange juice and that higher levels of vitamin C likely result in longer teeth.
plot(data$len~data$supp)
plot(data$len~data$dose)
To test the first assertion, the following code performs a basic t-test. In this analysis, the null hypothesis states that how vitamin C is administered has no effect on tooth length. If one sets the alpha level at .05 for this null hypothesis, the test indcates that the difference between the two conditions (20.66 vs. 16.96) is not significant, meaning that null hypothesis cannot be rejected, t(55.31) = 1.9153, p > .05.
t.test(data$len~data$supp)
##
## Welch Two Sample t-test
##
## data: data$len by data$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
To test the second assertion, that doseage level appears to have an effect on tooth length, the following code first subsets the data to allow for t-tests between doseage levels 1 & 2, levels 2 & 3 and levels 1 & 3. The null hypothesis for each of these tests is that doseage level has no impact on tooth length. The interpretation of the statistical significance assumes an alpha level of 0.5.
The first test indicates that doseage level 1 (0.5) and doseage level 2 (1.0) lead to significantly different teeth sizes, t(37.99) = -6.48, p < .05. Because subjects at doseage level 1.0 have larger mean teeth size (10.61 vs. 19.74), one may conclude that the 1.0 dosage level is associated with larger teeth.
The second test indicates that doseage level 2 (1.0) and doseage level 3 (2.0) lead to significantly different teeth sizes, t(37.1) = -4.9, p < .05. Because subjects at doseage level 2.0 have larger mean teeth size (19.74 vs. 26.1), one may conclude that the 2.0 dosage level is associated with larger teeth.
The third test indicates that doseage level 1 (0.5) and doseage level 3 (2.0) lead to significantly different teeth sizes, t(36.88) = -11.8, p < .05. Because subjects at doseage level 2.0 have larger mean teeth size (10.61 vs. 26.1), one may conclude that the 2.0 dosage level is associated with larger teeth.
datasub1 <- subset(data, dose <= 1.0)
t.test(datasub1$len~datasub1$dose)
##
## Welch Two Sample t-test
##
## data: datasub1$len by datasub1$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
datasub2 <- subset(data, dose >= 1.0)
t.test(datasub2$len~datasub2$dose)
##
## Welch Two Sample t-test
##
## data: datasub2$len by datasub2$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
datasub3 <- subset(data, dose == 0.5 | dose == 2.0)
t.test(datasub3$len~datasub3$dose)
##
## Welch Two Sample t-test
##
## data: datasub3$len by datasub3$dose
## 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 in group 0.5 mean in group 2
## 10.605 26.100