Overview

Exploratory Data Analysis

Summary of Tooth Length
dose supp meanLen medLen
0.5 OJ 13.23 12.25
0.5 VC 7.98 7.15
1.0 OJ 22.70 23.45
1.0 VC 16.77 16.50
2.0 OJ 26.06 25.95
2.0 VC 26.14 25.95
For Code - refer Appendix

Confidence Interval Test and Hypothesis test.

I have done T-Confidence Interval Test(paired) for the data.For all the Hypothesis testing p-value >= 0.95.First, data for Orange Juice and Vitamin C is compared irrespective of dose.Assumption(Null Hypothesis) - Orange Juice and Vitamin C have same impact on tooth growth i.e. difference in means of both supplements is 0.

tVC <- ToothGrowth[1:30,]
tOJ <- ToothGrowth[31:60,]
tIntervalOJVC <- t.test(tOJ$len,tVC$len,paired = TRUE)

Second, at a dosage level comparison of two supplements is done.Assumption(Null Hypothesis) - Orange Juice and Vitamin C have same impact on tooth growth i.e. difference in means of both supplements for each dose is 0.For dose = 0.5

t05 <- filter(ToothGrowth, dose == 0.5)
tInterval05 <- t.test(filter(t05, supp == 'OJ')$len, filter(t05, supp == 'VC')$len, paired = TRUE)

For dose = 1

t1 <- filter(ToothGrowth, dose == 1)
tInterval1 <- t.test(filter(t1, supp == 'OJ')$len, filter(t1, supp == 'VC')$len, paired = TRUE)

For dose = 2

t2 <- filter(ToothGrowth, dose == 2)
tInterval2 <- t.test(filter(t2, supp == 'OJ')$len, filter(t2, supp == 'VC')$len, paired = TRUE)

Third, For a particular supplement, effect of increasing the dose.Assumption(Null Hypothesis) - Effect of increasing the dose from 0.5 to 1 is same as 1 to 2 for each supplement.For Vitamin C

tVC105 <- filter(tVC,dose==1)$len - filter(tVC,dose==0.5)$len
tVC21 <- filter(tVC,dose==2)$len - filter(tVC,dose==1)$len
tIntervalVC <- t.test(tVC21,tVC105,paired = TRUE)

For Orange Juice

tOJ105 <- filter(tOJ,dose==1)$len - filter(tOJ,dose==0.5)$len
tOJ21 <- filter(tOJ,dose==2)$len - filter(tOJ,dose==1)$len
tIntervalOJ <- t.test(tOJ21,tOJ105,paired = TRUE)

Appendix

Code of Exploratory Data Analysis

library(ggplot2)
data("ToothGrowth")
g <- ggplot(ToothGrowth,aes(x = dose,y = len, color = supp))
g <- g + geom_point()
g <- g + stat_summary(aes(group=1),geom = "line",fun.y = mean, col="black", size = 1)
g + facet_grid(. ~ supp)
library(xtable); library(dplyr); library(knitr)
tGroup <- group_by(ToothGrowth,dose,supp)
tSummary <- kable(summarize(tGroup,meanLen = mean(len), medLen = median(len)),
format = "pandoc", caption = "Summary of Tooth Length")
tSummary