11.07.2015 Views

Preface to First Edition - lib

Preface to First Edition - lib

Preface to First Edition - lib

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ANALYSIS USING R 85being far more than for the low-protein diet. A smaller difference is seen forthe source fac<strong>to</strong>r with beef leading <strong>to</strong> a higher gain than cereal.To apply analysis of variance <strong>to</strong> the data we can use the aov function in Rand then the summary method <strong>to</strong> give us the usual analysis of variance table.The model formula specifies a two-way layout with interaction terms, wherethe first fac<strong>to</strong>r is source, and the second fac<strong>to</strong>r is type.R> wg_aov summary(wg_aov)Df Sum Sq Mean Sq F value Pr(>F)source 1 220.9 220.9 0.9879 0.32688type 1 1299.6 1299.6 5.8123 0.02114source:type 1 883.6 883.6 3.9518 0.05447Residuals 36 8049.4 223.6Figure 5.2R output of the ANOVA fit for the weightgain data.The resulting analysis of variance table in Figure 5.2 shows that the maineffect of type is highly significant confirming what was seen in Figure 5.1.The main effect of source is not significant. But interpretation of both thesemain effects is complicated by the type × source interaction which approachessignificance at the 5% level. To try <strong>to</strong> understand this interaction effect it willbe useful <strong>to</strong> plot the mean weight gain for low- and high-protein diets for eachlevel of source of protein, beef and cereal. The required R code is given withFigure 5.3. From the resulting plot we see that for low-protein diets, the useof cereal as the source of the protein leads <strong>to</strong> a greater weight gain than usingbeef. For high-protein diets the reverse is the case with the beef/high dietleading <strong>to</strong> the highest weight gain.The estimates of the intercept and the main and interaction effects can beextracted from the model fit byR> coef(wg_aov)(Intercept) sourceCereal typeLow100.0 -14.1 -20.8sourceCereal:typeLow18.8Note that the model was fitted with the restrictions γ 1 = 0 (corresponding <strong>to</strong>Beef) and β 1 = 0 (corresponding <strong>to</strong> High) because treatment contrasts wereused as default as can be seen fromR> options("contrasts")$contrastsunordered"contr.treatment"ordered"contr.poly"Thus, the coefficient for source of −14.1 can be interpreted as an estimate ofthe difference γ 2 − γ 1 . Alternatively, we can use the restriction ∑ i γ i = 0 by© 2010 by Taylor and Francis Group, LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!