In this experiment,we aim to find out the supplement and amount of dosage for the maximum tooth growth.
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 ...
names(ToothGrowth)<-c("Length","Supplement","Dose")
ggplot(ToothGrowth,aes(x=Supplement,y=Length))+geom_point(aes(fill=Dose,col=Dose))+labs(title="Growth Against Type of Supplement")
ggplot(ToothGrowth,aes(x=Dose,y=Length))+geom_point(aes(fill=Supplement,col=Supplement))+labs(title="Growth Against Amount of Dosage")
After some exploring,we can see that our data is stored in a data frame having 60 rows and 3 columns .The 3 variables include the length of tooth,the supplement used and the dosage of the supplement.Further,there are 2 types of Supplements,namely OJ & VC and they are provided in 4 different amounts of dosages,that are,0.5,1.0,1.5 and 2.0.Also both supplements are given to 30 participants each.
summary(ToothGrowth)
## Length Supplement 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
For deciding which supplement is better,we compare the two by testing the null hypothesis of no difference in means between the length achieved from both methods. Alternative hypothesis states that OJ is better than VC or the mean length achieved by OJ is greater than that of VC.
VC_Length<-ToothGrowth$Length[which(ToothGrowth$Supplement=="VC")]
OJ_Length<-ToothGrowth$Length[which(ToothGrowth$Supplement=="OJ")]
t.test(OJ_Length,VC_Length,alternative = "greater",paired=FALSE)
##
## Welch Two Sample t-test
##
## data: OJ_Length and VC_Length
## t = 1.9153, df = 55.309, p-value = 0.03032
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
## 0.4682687 Inf
## sample estimates:
## mean of x mean of y
## 20.66333 16.96333
Here we used Welch Two Sample T-test.The p-value is 3.03% which is less than 5% ,which is the alpha ,as default confidence interval was 95%.Therefore the null hypthesis is not significant and we may reject it.This means that our alternative hypothesis is true-OJ is better for tooth growth than VC.
Firstly we test for 0.5 and 1.0 dosage. Null Hypotheis:There is no difference between the length achieved due to dosage of 0.5 to that of 1.0 Alternative Hypothesis:The length achieved due to 0.5 dosage is less than that of 1.0
dose_0.5<-ToothGrowth$Length[which(ToothGrowth$Dose==0.5)]
dose_1.0<-ToothGrowth$Length[which(ToothGrowth$Dose==1.0)]
dose_2.0<-ToothGrowth$Length[which(ToothGrowth$Dose==2.0)]
t.test(dose_0.5,dose_1.0,paired = FALSE,conf.level = 0.95,var.equal = FALSE,alternative = "less")
##
## Welch Two Sample t-test
##
## data: dose_0.5 and dose_1.0
## t = -6.4766, df = 37.986, p-value = 6.342e-08
## alternative hypothesis: true difference in means is less than 0
## 95 percent confidence interval:
## -Inf -6.753323
## sample estimates:
## mean of x mean of y
## 10.605 19.735
Since p-value is less than alpha ,we reject null hypthesis which means that alternative hyothesis is true indicating that a dosage of 0.5 has lesser impact on growth than a dosage of 1.0 Next,we test for 1.0 and 2.0 dosage
t.test(dose_1.0,dose_2.0,paired = FALSE,conf.level = 0.95,var.equal = FALSE,alternative = "less")
##
## Welch Two Sample t-test
##
## data: dose_1.0 and dose_2.0
## t = -4.9005, df = 37.101, p-value = 9.532e-06
## alternative hypothesis: true difference in means is less than 0
## 95 percent confidence interval:
## -Inf -4.17387
## sample estimates:
## mean of x mean of y
## 19.735 26.100
Again,due to p-value being lower than alpha,we can reject null hypotheis say that Dose 1.0 has lower impact than dose 2.0 on growth. Further a pattern is clear here,the lesser the dosage ,the lower is the impact on growth.The same can be seen in the plot -Growth Against Dosage[Refer to the graph above] Hence we do not need to test between dosage 0.5 and 2.0,and directy infer that dosage of 0.5 has a lesser growth impact than that of 2.0.
In conclusion,we can say that OJ is a better supplement than VC.
A dosage of 2.0 is better than any dosage lower than 2.0,here better referring to a greater impact on Tooth Growth.