0% found this document useful (0 votes)
70 views6 pages

Stat Inference CPP 2

The document summarizes an analysis of the ToothGrowth data set, which contains observations of tooth growth in rats based on vitamin supplement (VC or OJ) and dose (0.5, 1.0, or 2.0 mg). Basic analyses include calculating means for each supplement/dose combination and performing t-tests to compare means. The t-tests show significant differences between supplements for the 0.5 and 1.0 mg doses but not the 2.0 mg dose. They also show increased tooth growth with higher doses for both supplements. The analysis concludes higher doses generally lead to more growth and the VC supplement is more effective at lower doses.

Uploaded by

F
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views6 pages

Stat Inference CPP 2

The document summarizes an analysis of the ToothGrowth data set, which contains observations of tooth growth in rats based on vitamin supplement (VC or OJ) and dose (0.5, 1.0, or 2.0 mg). Basic analyses include calculating means for each supplement/dose combination and performing t-tests to compare means. The t-tests show significant differences between supplements for the 0.5 and 1.0 mg doses but not the 2.0 mg dose. They also show increased tooth growth with higher doses for both supplements. The analysis concludes higher doses generally lead to more growth and the VC supplement is more effective at lower doses.

Uploaded by

F
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Statistical Inference Course Project - Part II - Basic

Inferential Data Analysis


Francisco Nazar A.
March 14, 2015
Load and explore the ToothGrowth data
library(datasets)
data(ToothGrowth)
There are 60 observations, each observation containing the variables len (length), supp (supplement) and
dose. There are two types of supplements (VC, OJ) and three types of doses (0.5, 1.0, 2.0). This can be
viewed using the names() command, the dim() command, and the unique() command. (Code not shown for
saving space)

Basic data analysis.


The data can be viewed conviniently with a boxplot :
library(ggplot2)
ggplot(ToothGrowth, aes(x=supp, y=len)) +
ggtitle("ToothGrowth Length vs Supplement typeby Dose") +
geom_boxplot(aes(fill=factor(supp))) + geom_jitter() + facet_grid(.~dose)

ToothGrowth Length vs Supplement typeby Dose


0.5

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

Min. 1st Qu.


4.20
5.95

Median
7.15

Mean 3rd Qu.


7.98
10.90

Max.
11.50

analogously (see Appendix):

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

Orange Juice supplement (OJ) the mean is 13.2


Vitamin C supplement (VC) the mean is 16.8
Orange Juice supplement (OJ) the mean is 22.7
Vitamin C supplement (VC) the mean is 26.1
Orange Juice supplement (OJ) the mean is 26.1

Confidence intervals and hypothesis tests.


Lets do an hypothesis test. First, the inicial three null hypothesis will focus on the difference between
supplements, for the same dose:
H0: (VC, 0.5) = (OJ, 0.5)
H0: (VC, 1.0) = (OJ, 1.0)
H0: (VC, 2.0) = (OJ, 2.0)
secondly, 4 null hypothesis will be stated on the difference between doses, for the same supplement:

H0:
H0:
H0:
H0:

(VC, 0.5) = (VC, 1.0)


(VC, 1.0) = (VC, 2.0)
(OJ, 0.5) = (OJ, 1.0)
(OJ, 1.0) = (OJ, 2.0)

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

Welch Two Sample t-test


data: ToothGrowth[which(ToothGrowth$dose == 0.5 & ToothGrowth$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:
2

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

95% Confidence interval

p-value

H0

Orange Juice

1.0 mg with 0.5 mg

5.52 - 13.42

8.785e-05

Rejected

Orange Juice

2.0 mg with 1.0 mg

0.19 -6.53

0.039

Rejected

Vitamin C

1.0 mg with 0.5 mg

6.31 - 11.27

6.811e-07

Rejected

Vitamin C

2.0 mg with 1.0 mg

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

Min. 1st Qu.


4.20
5.95

Median
7.15

Mean 3rd Qu.


7.98
10.90

Max.
11.50

for 0.5 mg doses and Orange Juice supplement (OJ) the mean is 13.2
##
##

Min. 1st Qu.


8.20
9.70

Median
12.25

Mean 3rd Qu.


13.23
16.18

Max.
21.50

for 1.0 mg doses and Vitamin C supplement (VC) the mean is 16.8
##
##

Min. 1st Qu.


13.60
15.27

Median
16.50

Mean 3rd Qu.


16.77
17.30

Max.
22.50

for 1.0 mg doses and Orange Juice supplement (OJ) the mean is 22.7
##
##

Min. 1st Qu.


14.50
20.30

Median
23.45

Mean 3rd Qu.


22.70
25.65

Max.
27.30

for 2.0 mg doses and Vitamin C supplement (VC) the mean is 26.1
##
##

Min. 1st Qu.


18.50
23.38

Median
25.95

Mean 3rd Qu.


26.14
28.80

Max.
33.90

for 2.0 mg doses and Orange Juice supplement (OJ) the mean is 26.1
##
##

Min. 1st Qu.


22.40
24.58

Median
25.95

Mean 3rd Qu.


26.06
27.08

Max.
30.90

Actual computation of confidence intervals and t.tests


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)

##
##
##
##
##
##
##
##
##
##
##

Welch Two Sample t-test


data: ToothGrowth[which(ToothGrowth$dose == 0.5 & ToothGrowth$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 of x mean of y
13.23
7.98

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

Welch Two Sample t-test


data: ToothGrowth[which(ToothGrowth$dose == 1 & ToothGrowth$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 of x mean of y
22.70
16.77

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

Welch Two Sample t-test


data: ToothGrowth[which(ToothGrowth$dose == 2 & ToothGrowth$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 of x mean of y
26.06
26.14

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

Welch Two Sample t-test


5

##
##
##
##
##
##
##
##
##

data: ToothGrowth[which(ToothGrowth$dose == 1 & ToothGrowth$supp ==


t = 5.0486, df = 17.698, p-value = 8.785e-05
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
5.524366 13.415634
sample estimates:
mean of x mean of y
22.70
13.23

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

Welch Two Sample t-test


data: ToothGrowth[which(ToothGrowth$dose == 2 & ToothGrowth$supp ==
t = 2.2478, df = 15.842, p-value = 0.0392
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
0.1885575 6.5314425
sample estimates:
mean of x mean of y
26.06
22.70

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

Welch Two Sample t-test


data: ToothGrowth[which(ToothGrowth$dose == 1 & ToothGrowth$supp ==
t = 7.4634, df = 17.862, p-value = 6.811e-07
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
6.314288 11.265712
sample estimates:
mean of x mean of y
16.77
7.98

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

Welch Two Sample t-test


data: ToothGrowth[which(ToothGrowth$dose == 2 & ToothGrowth$supp ==
t = 5.4698, df = 13.6, p-value = 9.156e-05
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
5.685733 13.054267
sample estimates:
mean of x mean of y
26.14
16.77
6

and ToothGrowth[which(ToothGrow

You might also like