A built-in demo for the data object ToothGrowth{datasets} is run by issuing the following command:

Replicate the analysis in the style of the headache study to investigate if type of vitamin supplement has an effect on teeth growth in guinea pigs. For this exercise, we shall ignore the dose variable.

[Solution and Answer]

Check the data structure

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

ToothGrowth is a data frame with 60 observations and 3 variables: len, supp, and dose. supp is a factorial variable. len and dose are numerical variables.

Summarize the data

      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  

Description statistics and data visualization

Find the average length of two groups of supplement.

Draw the box plots of length of two groups of supplement.

Compare to subjects in the group of VC supplement, subjects in the group of OJ supplement seemed to have higher lengths.

Hypothesis testing

Does type of vitamin supplement have an effect on teeth growth in guinea pigs?

\(H_0: \mu_{OJ} = \mu_{OJ}\)
\(H_1: \mu_{VC} \neq \mu_{VC}\)

Check the normality first.


    Shapiro-Wilk normality test

data:  resid(ToothGrowth_lm)
W = 0.96949, p-value = 0.1378

The normality assumption held. We conducted the independent two sample t-test.


    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 

Since \(p > \alpha =.05\), we retain \(H_0\). Two types of supplement did not make guinea pigs have significantly different lengths.