Boxplots

Supp<-ggplot(aes(y = len, x = supp), data = ToothGrowth) + geom_boxplot()
Supp<-Supp + labs(title="Delivery Method vs. Tooth Growth", x="Delivery Method", y="Tooth Growth")
Supp

Dose<- ggplot(aes(y = len, x = as.factor(dose)), data = ToothGrowth) + geom_boxplot()
Dose<-Dose + labs(title="Dose vs. Tooth Growth", x="Dose", y="Tooth Growth")
Dose

toothBoth<-ggplot(aes(y = len, x = supp, fill=as.factor(dose)), data = ToothGrowth) + geom_boxplot()
toothBoth<-toothBoth + labs(title="Delivery Method and Dose vs. Tooth Growth", x="Delivery Method", y="Tooth Growth") + guides(fill=guide_legend(title="Dose (mg/day)"))
toothBoth

Based on our boxplots, orange juice appears to have a higher mean growth than absorbic acid. It also appears that the higher the dose level, the more mean growth in teeth a guinea pig will have.

Confidence Intervals

vcAcid<-filter(ToothGrowth,ToothGrowth$supp=="VC")
vcAcidConf<-t.test(vcAcid$len,mu=0)
vcAcidConf
## 
##  One Sample t-test
## 
## data:  vcAcid$len
## t = 11.24, df = 29, p-value = 4.363e-12
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##  13.87675 20.04992
## sample estimates:
## mean of x 
##  16.96333
oj2Mg<-filter(ToothGrowth,ToothGrowth$supp=="OJ",ToothGrowth$dose==2)
oj2MgConf<-t.test(oj2Mg$len,mu=0)
oj2MgConf
## 
##  One Sample t-test
## 
## data:  oj2Mg$len
## t = 31.038, df = 9, p-value = 1.833e-10
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##  24.16069 27.95931
## sample estimates:
## mean of x 
##     26.06

t-tests

Problem 1

Null Hypothesis: The mean growth in guinea pigs who recieve orange juice is the same as guinea pigs who recieve absorbic acid. Alternative Hypothesis: The mean growth in guinea pigs who recieve orange juice is not the same as guinea pigs who recieve absorbic acid. \(H_0 : \mu _{OJ} = \mu _{VC}\) \(H_a : \mu _{OJ} \ne \mu _{VC}\)

OJ<-filter(ToothGrowth,ToothGrowth$supp=="OJ")
VC<-filter(ToothGrowth,ToothGrowth$supp=="VC")

t.test(OJ$len,VC$len)
## 
##  Welch Two Sample t-test
## 
## data:  OJ$len and VC$len
## 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

The P value from our test is 1.9153 and the p value is 0.06063. From our results, we can fail to reject the null hypothesis based on our p value being larger than .05. From our data, there is not enough data to suggest that there is a true difference between these two populations.

Problem 2

Null Hypothesis: The mean growth of 1mg of orange juice and 2mg of orange juice are the same. Alternative Hypothesis: The mean growth of 1mg of orange Juice is less than the mean growth of 2mg of orange juice. \(H_0 : \mu _{OJ1Mg} = \mu _{OJ2Mg}\) versus \(H_a : \mu _{OJ1Mg} \lt \mu _{OJ2Mg}\)

OJ1Mg<-filter(OJ,OJ$dose==1)

t.test(OJ1Mg$len,oj2Mg$len,alternative = "less",mu=0)
## 
##  Welch Two Sample t-test
## 
## data:  OJ1Mg$len and oj2Mg$len
## t = -2.2478, df = 15.842, p-value = 0.0196
## alternative hypothesis: true difference in means is less than 0
## 95 percent confidence interval:
##        -Inf -0.7486236
## sample estimates:
## mean of x mean of y 
##     22.70     26.06

The values from our test are the following: t = -2.2478, p-value = 0.0196 The results are significant at the level 0f .05 and lead us to reject the null hypothesis. There is true difference between the mean growth of 1mg test of OJ Guinea Pigs and mean growth of 2mg of OJ Guinea Pigs.

Problem 3

Null Hypothesis: The mean growth of 1mg of absorbic acid and 2mg of absorbic acid are the same. Alternative Hypothesis: The mean growth of 1mg of absorbic acid is less than the mean growth of 2mg of absorbic acid. \(H_0 : \mu _{VC1Mg} = \mu _{VC2Mg}\) versus \(H_a : \mu _{VC1Mg} \lt \mu _{VC2Mg}\)

VC1Mg<-filter(VC,VC$dose==1)
VC2Mg<-filter(VC,VC$dose==2)

t.test(VC1Mg$len,VC2Mg$len,alternative="less",mu=0)
## 
##  Welch Two Sample t-test
## 
## data:  VC1Mg$len and VC2Mg$len
## t = -5.4698, df = 13.6, p-value = 4.578e-05
## alternative hypothesis: true difference in means is less than 0
## 95 percent confidence interval:
##       -Inf -6.346525
## sample estimates:
## mean of x mean of y 
##     16.77     26.14

The results of our test are the following: t = -5.4698, df = 13.6, p-value = 4.578e-05 The results are significant at the level 0f .05 and lead us to reject the null hypothesis. There is true difference between the mean growth of 1mg test of absorbic acid Guinea Pigs and mean growth of 2mg of absorbic acid Guinea Pigs.

Problem 4

Null Hypothesis: The mean growth between guinea pigs who receive 1mg of absorbic acid and those who recieve 1mg of orange juice are the same. Alternative Hypothesis: The mean growth between guinea pigs who receive 1mg of absorbic acid is not the same than those who recieve 1mg of orange juice. \(H_0 : \mu _{OJ1Mg} = \mu _{VC1Mg}\) \(H_a : \mu _{OJ1Mg} \ne \mu _{VC1Mg}\)

VC1Mg<-filter(VC,VC$dose==1)

t.test(OJ1Mg$len,VC1Mg$len)
## 
##  Welch Two Sample t-test
## 
## data:  OJ1Mg$len and VC1Mg$len
## 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 of x mean of y 
##     22.70     16.77

The results are our test are the following: t = 4.0328, p-value = 0.001038 The results are significant at the level 0f .05 and lead us to reject the null hypothesis. There is true difference between the mean growth of 1mg dose of absorbic acid in Guinea Pigs and mean growth of 1mg dose of orange juice in Guinea Pigs.

Problem 5

Null Hypothesis: The mean growth between guinea pigs who receive 2mg of absorbic acid and those who recieve 2mg of orange juice are the same. Alternative Hypothesis: The mean growth between guinea pigs who receive 2mg of absorbic acid is not the same as those who recieve 2mg of orange juice.

t.test(oj2Mg$len,VC2Mg$len)
## 
##  Welch Two Sample t-test
## 
## data:  oj2Mg$len and VC2Mg$len
## 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 of x mean of y 
##     26.06     26.14

The results of our test are the following: t = -0.046136, p-value = 0.9639 The results are not significant at the level 0f .05 and lead us to fail to reject the null hypothesis. There is not a true difference between the mean growth of 2mg dose of absorbic acid in Guinea Pigs and mean growth of 2mg dose of orange juice in Guinea Pigs.