Project Description

Now in the second portion of the class, we’re going to analyze the ToothGrowth data in the R datasets package.

1 - Load the ToothGrowth data and perform some basic exploratory data analyses

2 - Provide a basic summary of the data.

3 - Use confidence intervals and/or hypothesis tests to compare tooth growth by supp and dose. (Only use the techniques from class, even if there’s other approaches worth considering)

4 - State your conclusions and the assumptions needed for your conclusions.

Some criteria that you will be evaluated on

1 - Load the ToothGrowth data and perform some basic exploratory data analyses

ToothGrowth {datasets}

The Effect of Vitamin C on Tooth Growth in Guinea Pigs

Description

The response is the length of odontoblasts (teeth) in each of 10 guinea pigs at each of three dose levels of Vitamin C (0.5, 1, and 2 mg) with each of two delivery methods (orange juice or ascorbic acid).

Usage

ToothGrowth

Format

A data frame with 60 observations on 3 variables.

[,1] len numeric Tooth length

[,2] supp factor Supplement type (VC or OJ).

[,3] dose numeric Dose in milligrams.

Source

C. I. Bliss (1952) The Statistics of Bioassay. Academic Press.

References

McNeil, D. R. (1977) Interactive Data Analysis. New York: Wiley.

library(datasets)
data(ToothGrowth)
dim(ToothGrowth)
## [1] 60  3
head(ToothGrowth)
##    len supp dose
## 1  4.2   VC  0.5
## 2 11.5   VC  0.5
## 3  7.3   VC  0.5
## 4  5.8   VC  0.5
## 5  6.4   VC  0.5
## 6 10.0   VC  0.5

2 - Provide a basic summary of the data.

summary(ToothGrowth)
##       len        supp         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
c(round(mean(ToothGrowth$len),3) , round(sd(ToothGrowth$len),3),round(var(ToothGrowth$len),3))
## [1] 18.813  7.649 58.512
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
summary(ToothGrowth)
##       len        supp     dose   
##  Min.   : 4.20   OJ:30   0.5:20  
##  1st Qu.:13.07   VC:30   1  :20  
##  Median :19.25           2  :20  
##  Mean   :18.81                   
##  3rd Qu.:25.27                   
##  Max.   :33.90

3 - Use confidence intervals and/or hypothesis tests to compare tooth growth by supp and dose. (Only use the techniques from class, even if there’s other approaches worth considering)

Graphical analysis of data:

library(ggplot2)

ggplot(ToothGrowth,aes(x=factor(dose),y=len,fill=factor(dose))) + 
    geom_boxplot(notch=F) +
    facet_grid(.~supp) +
    scale_x_discrete("Dosage (mg)") +   
    scale_y_continuous("Tooth Length") +  
    scale_fill_discrete(name="Dose (mg)") + 
    ggtitle("Effect of Supplement Type and Dosage on Tooth Growth")

The condifence intervals (95%) are:

x <- ToothGrowth$len[ToothGrowth$supp=="OJ" & ToothGrowth$dose == 0.5]
y <- ToothGrowth$len[ToothGrowth$supp=="VC" & ToothGrowth$dose == 0.5]
d05 <- c(round(mean(x),2),
  (round(mean(x) + c(-1,1) * qnorm(0.975) * sd(x)/sqrt(length(x)),2)),
  round(mean(y),2),
  (round(mean(y) + c(-1,1) * qnorm(0.975) * sd(y)/sqrt(length(y)),2)))

x <- ToothGrowth$len[ToothGrowth$supp=="OJ" & ToothGrowth$dose == 1]
y <- ToothGrowth$len[ToothGrowth$supp=="VC" & ToothGrowth$dose == 1]
d10 <- c(round(mean(x),2),
  (round(mean(x) + c(-1,1) * qnorm(0.975) * sd(x)/sqrt(length(x)),2)),
  round(mean(y),2),
  (round(mean(y) + c(-1,1) * qnorm(0.975) * sd(y)/sqrt(length(y)),2)))

x <- ToothGrowth$len[ToothGrowth$supp=="OJ" & ToothGrowth$dose == 2]
y <- ToothGrowth$len[ToothGrowth$supp=="VC" & ToothGrowth$dose == 2]
d20 <- c(round(mean(x),2),
  (round(mean(x) + c(-1,1) * qnorm(0.975) * sd(x)/sqrt(length(x)),2)),
  round(mean(y),2),
  (round(mean(y) + c(-1,1) * qnorm(0.975) * sd(y)/sqrt(length(y)),2)))

1 - dosage 0.5 mg

OJ-mean OJ-lower OJ-upper VC-mean VC-lower VC-upper

## [1] 13.23 10.47 15.99  7.98  6.28  9.68

2 - dosage 1.0 mg

OJ-mean OJ-lower OJ-upper VC-mean VC-lower VC-upper

## [1] 22.70 20.28 25.12 16.77 15.21 18.33

3 - dosage 2.0 mg

OJ-mean OJ-lower OJ-upper VC-mean VC-lower VC-upper

## [1] 26.06 24.41 27.71 26.14 23.17 29.11

4. State your conclusions and the assumptions needed for your conclusions.

Based on the analysis:

  • For lower dosages (0.5 and 1.0 mg), OJ provides more tooth growth than VC;

  • For 2.0mg dosage tooth growth is teh same for both supplement methods;

  • Higher dosages give more growth, indepedent of supplemetn method