Data Loading

## '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 ...
##       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

Exploratory Data Analyses

Summary of Data

There are 60 observations and 3 variables. The OJ supplement seems to have more of an effect on tooth length than VC for the 1.0 mg and 1.5 mg doses. However, for a dose of 2.0 mg, it seems that the affect on tooth length is comparable for OJ and VC. Overall, it also seems that the larger the dose, the larger the effect on tooth length, independent of the actual supplement.

Confidence Intervals and Hypothesis Testing.

Comparing VC and OJ for 0.5mg dose.

## 
##  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

The p-value = 0.0064.

Comparing VC and OJ for 1.0mg dose.

## 
##  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

The p-value = 0.0010.

Comparing VC and OJ for 2.0mg dose.

## 
##  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

The p-value = 0.964.

Comparing 0.5mg and 1.0mg dosage, independent of supplement.

## 
##  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

The p-value < .000001.

Comparing 1.0mg and 2.0mg dosage, independent of supplement.

## 
##  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

The p-value < .0001

Conclusion

For the 0.5mg and 1.0mg doses, we can reject the null hypothesis, and can conclude that Orange Juice has a larger effect on tooth growth than Vitamin C. However, for the 2.0mg dosage, we cannot reject the null hypothesis and therefore draw no conclusions comparing Orange Juice and Vitamin C on tooth growth.

We can correctly reject the null hypothesis and conclude that the larger the dose, the larger the affect on tooth growth, independent of whether Orange Juice or Vitamin C was administered.

In the ToothGrowth dataset, we are assuming that only the 2 supplements and 3 doses are variables and all other variables for the 60 pigs is constant. The age and nutrition of the pigs, for example, would be variables that could possibly affect the tooth growth rates.

Appendix

R code for all parts of the Simulation exercise.

knitr::opts_chunk$set(echo = FALSE)
library(ggplot2)
library(gridExtra)

###Data Loading
data(ToothGrowth)
str(ToothGrowth)
summary(ToothGrowth)

###Exploratory Data Analyses
gT <- ggplot(ToothGrowth, aes(y = len, x = supp))
gT <- gT + geom_boxplot(aes(colour = supp))
gT <- gT + facet_wrap(. ~ dose)
gT <- gT + theme(plot.title = element_text(hjust = 0.5))
gT <- gT + ggtitle("Tooth Length by Supplement and Dose")
gT <- gT + labs(x = "Supplement", y = "Tooth Length")
gT

###Confidence Intervals and Hypothesis Testing
###Comparing VC and OJ for 0.5mg dose.
d05 <- ToothGrowth[ToothGrowth$dose == 0.5,]
t.test(len ~ supp, data = d05)

###Confidence Intervals and Hypothesis Testing
###Comparing VC and OJ for 0.5mg dose.
d10 <- ToothGrowth[ToothGrowth$dose == 1.0,]
t.test(len ~ supp, data = d10)

###Confidence Intervals and Hypothesis Testing
###Comparing VC and OJ for 0.5mg dose.
d20 <- ToothGrowth[ToothGrowth$dose == 2.0,]
t.test(len ~ supp, data = d20)

###Confidence Intervals and Hypothesis Testing
###Comparing 0.5mg and 1.0mg dosage, independent of supplement.
dLight <- ToothGrowth[ToothGrowth$dose < 2.0,]
t.test(len ~ dose, data = dLight)

###Confidence Intervals and Hypothesis Testing
###Comparing 0.5mg and 1.0mg dosage, independent of supplement.
dHeavy <- ToothGrowth[ToothGrowth$dose > 0.5,]
t.test(len ~ dose, data = dHeavy)