Basic exporatory analysis

Since there are two supplements, 3 different dosages, we will provide two graphs, one is supplements with different dosages, the other is dosages with two different supplements.

Below is a graph for each supplement with different dosages.

Below is a graph for each dosages with different supplements.

Brief Summary

A brief summary is given below.

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

Assumptions

  1. The data comes from a random experiement, samples are assigned to dose usage randomly. All other factors besides dosage and supplement are strictly controlled. 2. The sample can well represent the population.
  2. For T-test, the variances are equal among all the data in t-test.

Compart Data with Supp and Dose

1. T-test for Mean Difference by Supplement

Comparing data with Supplement, divide data into two group, OJ and OC.

The null hypothesis H_0: the mean different between OJ and OC is 0. 95% condfident interval is used.

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

2. T-test for Mean Different by Dosages

Divide data into 3 groups, dosage 0.5, 1.0 and 2.0.

Next,3 t-test are used to test among 3 dosages. DF=19, 95%, from t-table, the t-value is 2.093. Three comparisions are made, between 0.5 and 1.0; 1.0 and 2.0; 0.5 and 2.0

The null hypothes H_0: there is no difference in mean among 3 dosages.

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

3.T-test for mean difference of supplement with dosage

Note that this is a more specify test.We test the difference of supplement under three different dosage levels.

## 
##  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
## 
##  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
## 
##  Welch Two Sample t-test
## 
## data:  len by supp
## t = -0.0461, 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

Conclusion

1.For different supplement type, there is no significant difference when using OJ or OC.

2.For different dosage use, 2mg has no significant difference on growth whethere is under OJ or OC.

  1. Under 0.5mg and 1.0mg treatment, VC has a more significant growth effect.

  2. For each dosage, all three have significant growth effect.

Appendix

library(ggplot2)
ggplot(ToothGrowth, aes(x=factor(dose), y=len, fill=factor(dose)))+
  geom_boxplot()+
  facet_grid(.~supp)+
  ggtitle("supplement with 3 dosages")
ggplot(ToothGrowth, aes(x=factor(supp), y=len, fill=factor(supp)))+
  geom_boxplot()+
  facet_grid(.~dose)+
  ggtitle("dosage with 2 supplements")
data= ToothGrowth
summary(data)
t.test(len~supp,data=ToothGrowth,pair=FALSE)
a<-subset(ToothGrowth, dose %in% c(0.5,1.0))
b<-subset(ToothGrowth, dose %in% c(1.0,2.0))
c<-subset(ToothGrowth, dose %in% c(0.5,2.0))
t.test(len~dose,data=a)
t.test(len~dose,data=b)
t.test(len~dose,data=c)
first = subset(data,dose==0.5)
second = subset(data,dose==1.0)
third = subset(data,dose==2.0)
t.test(len~supp,data=first)
t.test(len~supp,data=second)
t.test(len~supp,data=third)