This is the second portion of the Coursera Statistical Inference course project. We will analyze the ToothGrowth data in the R datasets package to determine if the Vitmain C has an effect on tooth growth in guinea pigs.
1) Loading ToothGrowth dataset and performing basic exploratory data analyis
hist(ToothGrowth$len, freq =FALSE, ylim =c(0.00, 0.06))curve(dnorm(x, mean =mean(ToothGrowth$len), sd =sd(ToothGrowth$len)), add =TRUE, col ="blue")
2) Basic summary of ToothGrowth dataset
Code
summary(ToothGrowth)
len supp dose
Min. : 4.20 OJ:30 0.5:20
1st Qu.:13.07 VC:30 1 :20
Median :19.25 2 :20
Mean :18.81
3rd Qu.:25.27
Max. :33.90
Code
library(ggplot2)ggplot(ToothGrowth, aes(x = supp, y = len)) +geom_boxplot(aes()) +labs(title ="Tooth Length v. Dose Amount", x ="Supplement Type", y ="Tooth Length")
Code
ggplot(ToothGrowth, aes(x = dose, y = len)) +geom_boxplot(aes()) +labs(title ="Tooth Length v. Supplement Type", x ="Dose Amount", y ="Tooth Length")
3) Using Confidence Interval and T-Test to compare tooth growth by supp and dose
It appears the dataset is fairly normal. With this smaller dataset, we’ll be using T-Test to test if delivery method and/or dose amount affects tooth growth
Hypothesis 1: Vitamin C and Orange Juice result in same tooth growth
Code
t.test(len ~ supp, paired =FALSE, var.equal =TRUE, data = ToothGrowth)
Two Sample t-test
data: len by supp
t = 1.9153, df = 58, p-value = 0.06039
alternative hypothesis: true difference in means between group OJ and group VC is not equal to 0
95 percent confidence interval:
-0.1670064 7.5670064
sample estimates:
mean in group OJ mean in group VC
20.66333 16.96333
The 95% confidence interval includes 0 and the p-value is greater than 0.05 therefore we fail to reject the null hypothesis that vitamin C and orange juice result in the same amount of tooth growth.
Hypothesis 2: Increasing dose amount results in same tooth growth
All three 95% confidence intervals do not contain 0 and all three P-Values are essentially 0 therefore we reject the null hypothesis that increasing the dosage will result in the same amount of tooth growth.
4) Conclusion
Working with the assumptions that the data is iid normal and variance is equal we can conclude that the supplement delivery (vitamin C or orange juice) has no affect on tooth growth. However, increasing dosage amount, regardless of delivery method, appears to result in increase tooth growth