Part 2 Inferential Data Analysis

Now in the second portion of the project, we’re going to analyze the ToothGrowth data in the R datasets package. https://stat.ethz.ch/R-manual/R-devel/library/datasets/html/ToothGrowth.html #### Provide a basic summary of the data.

data(ToothGrowth)
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
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.3.3
    ggplot(ToothGrowth,aes(x=factor(dose),y=len,fill=factor(dose))) + 
    geom_boxplot()+
    facet_grid(.~supp) +
    scale_fill_discrete(name="Dose (mg/day)") + 
    theme_bw() +
    theme(plot.title = element_text(hjust = 0.5))+
    ggtitle("Effect of Supplement Type and Dosage on Tooth Growth")+
    labs(x = "Dosage (mg)", y ="Tooth Length") 

Use confidence intervals and/or hypothesis tests to compare tooth growth by supp and dose.

We will compare the difference between the two types of supplements and see if we can reject the nulle hypothesis: H0:The supplements types of vitamin C has no impact on the length of odontoblasts

t.test(len ~ supp, data = ToothGrowth)
## 
##  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

Since p-value is greater than 0.05 there is a low presumption against null hypothesis, it means that there is a no that much of a difference between both methods event though that their true difference in means is not equal to 0.

We will now compare the difference between the dose and see if we can reject the nulle hypothesis: H0:The dose levels of vitamin C has no impact on the length of odontoblasts

t.test(ToothGrowth$len, ToothGrowth$dose)
## 
##  Welch Two Sample t-test
## 
## data:  ToothGrowth$len and ToothGrowth$dose
## t = 17.81, df = 59.798, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  15.66453 19.62881
## sample estimates:
## mean of x mean of y 
## 18.813333  1.166667

Since the p-value aproximates to 0, there is a strong presumption against null hypothesis therefore we reject the null hypothesis.

State your conclusions and the assumptions needed for your conclusions.

There is not strong evidence that one supplements has more impact on the ToothGrowth than another two type of supplements based on the existing datasets and T statistics. However, there is strong evidence that there is a difference between the dose level, and the growth.