data("ToothGrowth")
dim(ToothGrowth)
## [1] 60 3
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
str(colnames(ToothGrowth))
## chr [1:3] "len" "supp" "dose"
library(ggplot2)
mean(ToothGrowth$len)
## [1] 18.81333
sd(ToothGrowth$len)
## [1] 7.649315
coplot(len ~ dose | supp, data = ToothGrowth, panel = panel.smooth,main = "ToothGrowth Data: Length vs dose, given type of supplement", ylab = "Length of Tooth Growth",xlab = "Dose Levels of Vitamin C")
### The average guinea pig length is 18.813 units with a standard deviation of 7.649. However,we are more interested in finding differences in tooth length accross different groups of supplement types, dose levels and their respective combinations. ### I, therefore plotted the conditioning plot as above. Following inferences can be sighted from the above conditioning plot ### 1) For 0.5 mg/day dose of vitamin C, the tooth length has outgrown in Orange Juice (OJ) supplements in comparison with ascorbic acid (a form of vitamin C and coded as VC hereafter). ### 2) For 1 mg/day dose of vitamin C, the tooth length has also outgrown in Orange Juice (OJ) supplements in comparison with VC. ### 3) For 1.5 mg/day dose of vitamin C, the tooth length has grown virtually the same as in case of in Orange Juice (OJ) supplements. ### 4) As the dosage increases the tooth growth increases.
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
t.test(len~supp,data = ToothGrowth,var.equal = FALSE)
##
## 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
t.test(ToothGrowth$len[ToothGrowth$dose==1],ToothGrowth$len[ToothGrowth$dose== 0.5])
##
## Welch Two Sample t-test
##
## data: ToothGrowth$len[ToothGrowth$dose == 1] and ToothGrowth$len[ToothGrowth$dose == 0.5]
## 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:
## 6.276219 11.983781
## sample estimates:
## mean of x mean of y
## 19.735 10.605
t.test(ToothGrowth$len[ToothGrowth$dose==2],ToothGrowth$len[ToothGrowth$dose== 0.5])
##
## Welch Two Sample t-test
##
## data: ToothGrowth$len[ToothGrowth$dose == 2] and ToothGrowth$len[ToothGrowth$dose == 0.5]
## 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:
## 12.83383 18.15617
## sample estimates:
## mean of x mean of y
## 26.100 10.605
t.test(ToothGrowth$len[ToothGrowth$dose==2],ToothGrowth$len[ToothGrowth$dose== 1])
##
## Welch Two Sample t-test
##
## data: ToothGrowth$len[ToothGrowth$dose == 2] and ToothGrowth$len[ToothGrowth$dose == 1]
## 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:
## 3.733519 8.996481
## sample estimates:
## mean of x mean of y
## 26.100 19.735