Statistical Inference Part2
Statistical Inference Part2
briofons
Saturday, January 24, 2015
The ToothGrowth dataset has information about the relation between the growth of teeth of guinea pigs at
each of three dose levels of Vitamin C from orange juice and ascorbic acid.
So we studied with supp and dose with confidence intervals
Question 1 Load the ToothGrowth data and perform some basic exploratory data analyses
library(datasets)
library(ggplot2)
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 ...
head(ToothGrowth)
##
##
##
##
##
##
##
Question 2
# Basic information about dataset
summary(ToothGrowth)
##
##
##
##
##
##
##
len
Min.
: 4.20
1st Qu.:13.07
Median :19.25
Mean
:18.81
3rd Qu.:25.27
Max.
:33.90
supp
OJ:30
VC:30
dose
Min.
:0.500
1st Qu.:0.500
Median :1.000
Mean
:1.167
3rd Qu.:2.000
Max.
:2.000
OJ
VC
0.5 1 2
10 10 10
10 10 10
boxplot(ToothGrowth$len ~ ToothGrowth$supp *
ToothGrowth$dose, data=ToothGrowth,
ylab="Tooth Length", main="Tooth Growth Data")
25
20
15
5
10
Tooth Length
30
35
OJ.0.5
VC.0.5
OJ.1
VC.1
OJ.2
VC.2
#Another way to plot the data to see difference in orange juice vs ascorbic acid
plot <- ggplot(ToothGrowth,
aes(x=factor(dose),y=len,fill=factor(dose)))
plot + geom_boxplot(notch=F) + facet_grid(.~supp) +
scale_x_discrete("Doses (mg)") +
scale_y_continuous("Length of Teeth") +
ggtitle("ToothGrowth data analysis")
VC
Length of Teeth
30
factor(dose)
0.5
20
1
2
10
0.5
0.5
Doses (mg)
Question 3 Use confidence intervals and hypothesis tests to compare tooth growth by supp and dose. (Use
the techniques from class even if theres other approaches worth considering)
t.test(len~supp, data = ToothGrowth)
##
##
##
##
##
##
##
##
##
##
##
p.value
Conf.Low Conf.High
3
## Equal Var
0.06039337 -0.1670064
## Unequal Var 0.06063451 -0.1710156
7.567006
7.571016
Conclusions
With the t-test for compare growth and dose based in our analysis we can say:
While doses are more we have more growth of the tooth so 2 mg has more impact than the other. And orange
juice and vitamin C has no effect on tooth growth.