Description of data

The response is 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).

  1. Load the ToothGrowth data and perform some basic exploratory data analyses We can also check the datatype of the variables
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 ...
  1. Provide a basic summary of the data.
ToothGrowth$dose <- factor(ToothGrowth$dose)
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

Exploratory Analysis

  1. For every dose level, let’s see how tooth leghth varies between the delivery methods.

We can infer that for dose levels of 0.5 and 1, Orange Juice (OJ) delivery resulted in longer tooth lengths that VC except for dose level 2 where VC delivery had both extreme tooth lengths.

library(ggplot2)

ggplot(ToothGrowth) +
 aes(x = "", y = len, fill = supp) +
 geom_boxplot() + 
 scale_fill_hue() +
 labs(x = "Dose levels", y = "Tooth Lenght", title = "Boxplot of Dose Levls") +
 theme_linedraw() +
 facet_wrap(vars(dose))

Check how many Dose were delivery via each method
Equal number of dose were delivered in each case as shown below

table(ToothGrowth$supp, ToothGrowth$dose)
##     
##      0.5  1  2
##   OJ  10 10 10
##   VC  10 10 10

Hypothesis Testing

  1. Does different supplementary delivery affect Toothgrowth? I will conduct a hypothesis test to answer this question. since the variables are independent, I’ll specify paired = F
with(ToothGrowth, t.test(len~supp, alternative = "two.sided", paired = F))
## 
##  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

Here H0: There's no difference in average tooth-length of supplemetary delivery. Since the CI -0.1710156 7.5710156 contains zero and also the p-value: .006 is greater that alpha of .5, we fail to reject the null hypothesis in favor of H0

  1. tooth-length vs Dose levels

I will create a utility function to subset data

tooth_sub <- function(sub){
        return(subset(ToothGrowth, dose %in% sub))
        }


Dose_05_10 <- tooth_sub(c(0.5, 1))
Dose_05_20 <- tooth_sub(c(0.5, 2))
Dose_10_20 <- tooth_sub(c(1, 2))

Dose_05 <- tooth_sub(c(0.5))
Dose_10 <- tooth_sub(c(1))
Dose_20 <- tooth_sub(c( 2))
  1. How does average tooth-growth differ in Dose level .5 and 1
with(Dose_05_10, t.test(len~dose, alternative = "two.sided", paired = F))
## 
##  Welch Two Sample t-test
## 
## data:  len by dose
## 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:
##  -11.983781  -6.276219
## sample estimates:
## mean in group 0.5   mean in group 1 
##            10.605            19.735

Here H0: There's no difference between dose level .5 average tooth-length and dose level 1. Since the CI does not contain zero and also the p-value is less than alpha of .5, we reject the null hypothesis in favor of Ha and conclude average Tooth-growth differ

  1. How does average tooth-growth differ in Dose level .5 and 2
with(Dose_05_20, t.test(len~dose, alternative = "two.sided", paired = F))
## 
##  Welch Two Sample t-test
## 
## data:  len by dose
## 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:
##  -18.15617 -12.83383
## sample estimates:
## mean in group 0.5   mean in group 2 
##            10.605            26.100

Here H0: There's no difference between dose level .5 average tooth-length and dose level 2. Since the CI does not contain zero and also the p-value is less than alpha of .5, we again reject the null hypothesis in favor of Ha and conclude average Tooth-growth differ

  1. How does average tooth-growth differ in Dose level .5 and 1
with(Dose_10_20, t.test(len~dose, alternative = "two.sided", paired = F))
## 
##  Welch Two Sample t-test
## 
## data:  len by dose
## 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:
##  -8.996481 -3.733519
## sample estimates:
## mean in group 1 mean in group 2 
##          19.735          26.100

Here H0: There's no difference between dose level 1 average tooth-length and dose level 2. Since the CI does not contain zero and also the p-value is less than alpha of .5, we reject the null hypothesis in favor of Ha and conclude average Tooth-growth differ

For each dose level, how does tooth-growth differ among suplementary delivery?

Here H0: There's no difference in average tooth-length of supplemetary delivery for all 3 cases

  1. Does .5
    The p-value: is less than alpha of .5, we reject the null hypothesis in favor of Ha and conclude average Tooth-growth differ
with(Dose_05, t.test(len~supp, alternative = "two.sided", paired = F))
## 
##  Welch Two Sample t-test
## 
## data:  len by supp
## t = 3.1697, df = 14.969, p-value = 0.006359
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  1.719057 8.780943
## sample estimates:
## mean in group OJ mean in group VC 
##            13.23             7.98
  1. Does 1
    The p-value: is less than alpha of .5, we reject the null hypothesis in favor of Ha and conclude average Tooth-growth differ
with(Dose_10, t.test(len~supp, alternative = "two.sided", paired = F))
## 
##  Welch Two Sample t-test
## 
## data:  len by supp
## t = 4.0328, df = 15.358, p-value = 0.001038
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  2.802148 9.057852
## sample estimates:
## mean in group OJ mean in group VC 
##            22.70            16.77
  1. Does 2
    The p-value: is greater than alpha of .5, we fail to reject the null hypothesis conclude average Tooth-growth does not differ
with(Dose_20, t.test(len~supp, alternative = "two.sided", paired = F))
## 
##  Welch Two Sample t-test
## 
## data:  len by supp
## t = -0.046136, df = 14.04, p-value = 0.9639
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -3.79807  3.63807
## sample estimates:
## mean in group OJ mean in group VC 
##            26.06            26.14

Asumptions

Conclusion