Lau Heng Kar
December 26, 2015 (Statistical Inference Course Project)
Now in the second portion of the class, we’re going to analyze the ToothGrowth data in the R datasets package.
require(datasets)
data(ToothGrowth)
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 ...
head(ToothGrowth, 3)
## len supp dose
## 1 4.2 VC 0.5
## 2 11.5 VC 0.5
## 3 7.3 VC 0.5
tail(ToothGrowth, 3)
## len supp dose
## 58 27.3 OJ 2
## 59 29.4 OJ 2
## 60 23.0 OJ 2
The response is the length of odontoblasts (teeth) in each of 10 guinea pigs at each of three dose levels of Vitamin C (0.5, 1, and 2 mg) with each of two delivery methods (orange juice or ascorbic acid).
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
table(ToothGrowth$dose, ToothGrowth$dose)
##
## 0.5 1 2
## 0.5 20 0 0
## 1 0 20 0
## 2 0 0 20
# data frame for both VC and OJ
groupVc <- ToothGrowth[ToothGrowth$supp=='VC',]
groupOJ <- ToothGrowth[ToothGrowth$supp=='OJ',]
# t.test for both group
difference <- groupVc$len - groupOJ$len
t1 <- t.test(groupVc$len, groupOJ$len, paired = TRUE)
Conclusion: We obtained p-value (0.0025498) and 95% confident internal (-5.9913414, -1.4086586). p-value is smaller than 0.05, then we can conclude that the averages of two groups are not significantly similar. This confirms that we can reject the null hypothesis H0 of equality of the means.
# t.test for both group for dose == 0.5
difference <- groupVc[groupVc$dose == "0.5", ]$len - groupOJ[groupOJ$dose == "0.5", ]$len
t2 <- t.test(groupVc[groupVc$dose == "0.5", ]$len, groupOJ[groupOJ$dose == "0.5", ]$len, paired = TRUE)
Conclusion: We obtained p-value (0.015472) and 95% confident internal (-9.2365417, -1.2634583). p-value is smaller than 0.05, then we can conclude that the averages of two groups are not significantly similar. This confirms that we can reject the null hypothesis H0 of equality of the means.
# t.test for both group for dose == 1
difference <- groupVc[groupVc$dose == "1", ]$len - groupOJ[groupOJ$dose == "1", ]$len
t3 <- t.test(groupVc[groupVc$dose == "1", ]$len, groupOJ[groupOJ$dose == "1", ]$len, paired = TRUE)
Conclusion: We obtained p-value (0.0082292) and 95% confident internal (-9.9080891, -1.9519109). p-value is smaller than 0.05, then we can conclude that the averages of two groups are not significantly similar. This confirms that we can reject the null hypothesis H0 of equality of the means.
# t.test for both group for dose == 2
difference <- groupVc[groupVc$dose == "2", ]$len - groupOJ[groupOJ$dose == "2", ]$len
t4 <- t.test(groupVc[groupVc$dose == "2", ]$len, groupOJ[groupOJ$dose == "2", ]$len, paired = TRUE)
Conclusion: We obtained p-value (0.9669567) and 95% confident internal (-4.1689765, 4.3289765). p-value is greater than 0.05, then we can conclude that the averages of two groups are significantly similar. This confirms that we can accept the null hypothesis H0 of equality of the means.
With the values obtained it can be assumed that there is a significantly similar in the growth of the tooth while the dose is 2.0 mg.