Now in the second portion of the class, we’re going to analyze the ToothGrowth data in the R datasets package.
Points 1 and 2.
"datasets" %in% row.names(installed.packages())
## [1] TRUE
library(datasets)
data("ToothGrowth")
dim(ToothGrowth)
## [1] 60 3
class(ToothGrowth)
## [1] "data.frame"
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
We got a 60 rows dataset for three variables: “Tooth length”, “Supplement lenght”, “Dose in milligrams per day”.
with(ToothGrowth, coplot(len ~ dose | supp))
The plot shows the response in the length of odontoblasts (cells responsible for tooth growth) in 60 guinea pigs. Each animal 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).
Use confidence intervals and/or hypothesis tests to compare tooth growth by supp and dose. (Only use the techniques from class, even if there’s other approaches worth considering).
Vitamin C delivery methods affect the tooth length of the guinea pigs? H0: true difference in means is equal to zero.
with(ToothGrowth, t.test(len[supp=="OJ"], len[supp=="VC"], paired = FALSE, var.equal = FALSE))
##
## Welch Two Sample t-test
##
## data: len[supp == "OJ"] and len[supp == "VC"]
## 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 of x mean of y
## 20.66333 16.96333
P-value of this test is 0.06. It could be interpreted as a lack of evidence to reject the null hypothesis. We cannot assume that the vitamin delivery method affect the tooth length.
Same t test for the tooth length of the group with vitamin C dosage.
with(ToothGrowth, t.test(len[dose==2], len[dose==1], paired = FALSE, var.equal = TRUE))
##
## Two Sample t-test
##
## data: len[dose == 2] and len[dose == 1]
## t = 4.9005, df = 38, p-value = 1.811e-05
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 3.735613 8.994387
## sample estimates:
## mean of x mean of y
## 26.100 19.735
We can reject the null hypothesis. As consequence, we can assume that the means of dosage change from 1mg to 2mg creates an positive effect on tooth length.
State your conclusions and the assumptions needed for your conclusions.
I suppose that Guinea pigs were randomly assigned to random treatments. Hence, the tests used a methodology adapt to indipendent samples.
The method of supplement has appearently a limitate effect on tooth growth. More relevant is the increase of the dosage, which leads to an increased tooth growth.