Overview / Synopsis

This assignment is to investigate the supplement type and/or dosage rate that affect to the tooth length in 60 guinea pigs. The analysis result indicates that 0.5 and 1.0 mg dosage rate has significantly positive effect to the tooth length for all supplement method.

Exploratory data analysis and Basic summary of data

Toothgrowth dataset represent the response of the length of odontoblasts (len: cells responsible for tooth growth) in 60 guinea pigs. Each animal received one of three dose levels of vitamin C (dose: 0.5, 1, and 2 mg/day) by one of two delivery methods, orange juice or ascorbic acid (supp: a form of vitamin C and coded as VC). Dataset consists of 60 observations with 3 variables.

## '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: Factor w/ 3 levels "0.5","1","2": 1 1 1 1 1 1 1 1 1 1 ...

The data correlation can be determined by plotting in order to visualized the effects of both supplement type and dosage rate. The plotting result is showed as following:

The plotting results apparently indicate the positive effect of the dosage rate on supplement type i.e. the tooth growth is increased along with the dosage rate.

Establish the key assumption

  1. All sample observations is independent and identically distributed (i.i.d.).
  2. Normal distribution can be verified by histogram plot based on supplement type. The plotting results indicate the Toothgrowth dataset is most likely follows a normal distribution.

3. Confidence intervals (C.I.) will be specified as 95%. 4. Variances of tooth growth are different in terms of both supplement type and dosage rate.

Conduct the hypothesis test

Hypotheis that need to be verified for this dataset is:

## 
##  Welch Two Sample t-test
## 
## data:  len by supp
## t = 1.9153, df = 55.309, p-value = 0.06063
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.1710156  7.5710156
## sample estimates:
## mean in group OJ mean in group VC 
##         20.66333         16.96333

The above result indicates the P-Value is 0.061, which > 0.05. Therefore, it is failed to reject the null hypothesis or there is not enough evidence to suggest that the supplement type impacts to the tooth growth. However, further analysis is required to revify whether if there is a difference between OJ and VC at different dosage rate e.g. 0.5, 1.0, and 2.0 mg.

## 
##  Welch Two Sample t-test
## 
## data:  len by 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 in group OJ mean in group VC 
##            13.23             7.98
## 
##  Welch Two Sample t-test
## 
## data:  len by 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 in group OJ mean in group VC 
##            22.70            16.77
## 
##  Welch Two Sample t-test
## 
## data:  len by supp
## t = -0.046136, 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 in group OJ mean in group VC 
##            26.06            26.14

Conclusion

Dosage rate has most likely positive effect to the tooth length for all supplement method. At 0.5 mg and 1.0 mg dosage rate, OJ supplement type has significantly positive effect to the tooth growth than the VC but has no significantly positive effect at 2.0 mg dosage rate.

Supporting Appendix

# Loading the dataset and library
library(datasets)
library(formatR)
library(ggplot2)
library(knitr)

# Prepare the data
ToothGrowth$dose <- as.factor(ToothGrowth$dose)

# Explore the dataset
str(ToothGrowth)

# Explore the data correlation
qplot(dose, len, data = ToothGrowth, facets = ~supp, main = "Tooth growth of guinea pigs 
      affected by supplement type and dosage rate", 
    xlab = "Dosage", ylab = "Tooth length") + geom_boxplot(aes(fill = dose)) + 
    theme(plot.title = element_text(hjust = 0.5))

# Verify the normal distribution
norm.plot <- ggplot(data = ToothGrowth, aes(x = len))
norm.plot + geom_density(color = "darkblue", fill = "lightblue") + 
    facet_grid(. ~ supp) + geom_vline(aes(xintercept = mean(len)), 
    color = "blue", linetype = "dashed", size = 1) + labs(title = "Density plot of tooth length", 
    x = "Tooth length") + theme(plot.title = element_text(hjust = 0.5))

# Verify the difference of Total OJ and VC
t.test(len ~ supp, data = ToothGrowth, paired = FALSE, var.equal = FALSE)

# Verify the difference of OJ and VC at 0.5 mg
dose05 <- subset(ToothGrowth, dose == 0.5)
t.test(len ~ supp, data = dose05, paired = FALSE, var.equal = FALSE)

# Verify the difference of OJ and VC at 1.0 mg
dose10 <- subset(ToothGrowth, dose == 1)
t.test(len ~ supp, data = dose10, paired = FALSE, var.equal = FALSE)

# Verify the difference of OJ and VC at 2.0 mg
dose20 <- subset(ToothGrowth, dose == 2)
t.test(len ~ supp, data = dose20, paired = FALSE, var.equal = FALSE)