Stat Inference CPP 2
Stat Inference CPP 2
30
len
factor(supp)
20
OJ
VC
10
OJ
VC
OJ
VC
OJ
supp
1
VC
In particular, for 0.5 mg doses and Vitamin C supplement (VC) the mean is 7.98
summary(ToothGrowth[which(ToothGrowth$dose==0.5 & ToothGrowth$supp=='VC'),]$len)
##
##
Median
7.15
Max.
11.50
for
for
for
for
for
0.5
1.0
1.0
2.0
2.0
mg
mg
mg
mg
mg
doses
doses
doses
doses
doses
and
and
and
and
and
H0:
H0:
H0:
H0:
The alternative hypothesis will be that the values are different(~=) or greater. We use the t.test function
for performing the hypothesis test. The results are as follow.
For the supplement analysis :
For the 0.5 mg dose, the 95% confidence interval is greater than 0, hence we reject the null hypothesis
in favour of the alternative hypothesis. This can also be noted with the p-value, which is 0.006359, less
than 0.05.
t.test(ToothGrowth[which(ToothGrowth$dose==0.5 & ToothGrowth$supp=='OJ'),]$len,
ToothGrowth[which(ToothGrowth$dose==0.5 & ToothGrowth$supp=='VC'),]$len)
##
##
##
##
##
##
##
and ToothGrowth[which(ToothGr
## 1.719057 8.780943
## sample estimates:
## mean of x mean of y
##
13.23
7.98
analogously (see Appendix):
For the 1.0 mg dose, the 95% confidence interval is again greater than 0, hence we reject the null
hypothesis in favour of the alternative hypothesis. This can also be noted with the p-value, which is
0.001038, less than 0.05.
For the 2.0 mg dose, the 95% confidence interval is NOT greater than 0, hence we CANNOT reject the
null hypothesis in favour of the alternative hypothesis. This can also be noted with the p-value, which
is 0.9639, GREATER than 0.05.
For the dose analysis a table is presented, for saving space:
Supplement
Dose comparison
p-value
H0
Orange Juice
5.52 - 13.42
8.785e-05
Rejected
Orange Juice
0.19 -6.53
0.039
Rejected
Vitamin C
6.31 - 11.27
6.811e-07
Rejected
Vitamin C
5.69 - 13.05
9.156e-05
Rejected
In other words, larger doses imply larger tooth growth with at least a 95% confidence.
Conclusions
Only for the samples studied, the conclusions are:
The results show that for low doses (0.5 mg, 1.0 mg) there is a clear difference in tooth growth between
supplements, being the Vitamin C supplement better for growth than the Orange Juice supplement.
On the other hand, for the 2.0 mg dose there appears not to be any improvement in growth between
the Vitamin C and the Orange Juice supplements.
The results show also that a larger dose implies more growth, with all the p-values very small, except
for the Orange Juice from 1.0 to 2.0 mg.
The basis assumptions in this analysis were:
All pigs are identical, this means the only variation on length was due to the supplement type and the
dosage.
The variances are assumed to be unequal.
The samples are unpaired.
The study is double blind, such that no placebo effect is considered.
Appendix
Actual computation of means and summaries
for 0.5 mg doses and Vitamin C supplement (VC) the mean is 7.98
summary(ToothGrowth[which(ToothGrowth$dose==0.5 & ToothGrowth$supp=='VC'),]$len)
##
##
Median
7.15
Max.
11.50
for 0.5 mg doses and Orange Juice supplement (OJ) the mean is 13.2
##
##
Median
12.25
Max.
21.50
for 1.0 mg doses and Vitamin C supplement (VC) the mean is 16.8
##
##
Median
16.50
Max.
22.50
for 1.0 mg doses and Orange Juice supplement (OJ) the mean is 22.7
##
##
Median
23.45
Max.
27.30
for 2.0 mg doses and Vitamin C supplement (VC) the mean is 26.1
##
##
Median
25.95
Max.
33.90
for 2.0 mg doses and Orange Juice supplement (OJ) the mean is 26.1
##
##
Median
25.95
Max.
30.90
##
##
##
##
##
##
##
##
##
##
##
and ToothGrowth[which(ToothGr
For the 1.0 mg dose, the 95% confidence interval is again greater than 0, hence we reject the null
hypothesis in favour of the alternative hypothesis. This can also be noted with the p-value, which is
0.001038, less than 0.05.
##
##
##
##
##
##
##
##
##
##
##
and ToothGrowth[which(ToothGrow
For the 2.0 mg dose, the 95% confidence interval is NOT greater than 0, hence we CANNOT reject the
null hypothesis in favour of the alternative hypothesis. This can also be noted with the p-value, which
is 0.9639, GREATER than 0.05.
##
##
##
##
##
##
##
##
##
##
##
and ToothGrowth[which(ToothGrow
For the orange juice, comparing the 0.5 mg with the 1.0 mg doses results in a rejection of the null
hypothesis:
t.test(ToothGrowth[which(ToothGrowth$dose==1.0 & ToothGrowth$supp=='OJ'),]$len,
ToothGrowth[which(ToothGrowth$dose==0.5 & ToothGrowth$supp=='OJ'),]$len)
##
##
##
##
##
##
##
##
##
##
##
and ToothGrowth[which(ToothGrow
For the orange juice, comparing the 1.0 mg with the 2.0 mg doses results in a rejection of the null
hypothesis:
##
##
##
##
##
##
##
##
##
##
##
and ToothGrowth[which(ToothGrow
For the Vitamin C, comparing the 0.5 mg with the 1.0 mg doses results in a rejection of the null
hypothesis:
##
##
##
##
##
##
##
##
##
##
##
and ToothGrowth[which(ToothGrow
For the Vitamin C, comparing the 1.0 mg with the 2.0 mg doses results in a rejection of the null
hypothesis:
##
##
##
##
##
##
##
##
##
##
##
and ToothGrowth[which(ToothGrow