11.07.2015 Views

statisticalrethinkin..

statisticalrethinkin..

statisticalrethinkin..

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

238 7. INTERACTIONSNow for the plotting. Here’s the strategy. I want each plot to show the bivariate relationshipbetween shade and blooms, as predicted by the model. Each plot will plot predictions fora different value of water. For this example, it is easy to pick which values of water to use,because there are only three values: −1, 0, and 1 (this variable was centered, recall). Sothe first plot will show the predicted relationship between blooms and shade, holding waterconstant at −1. e second plot will show the same relationship, but now holding waterconstant at 0. e final plot will hold water constant at 1. In addition, in each plot, I’ll showonly the raw data that has the water value appropriate in each case.You already know how to produce each plot, using the same kind of sapply code fromprevious chapters. I’m going to wrap that kind of code in a loop now, and iterate over thethree values of water.c. Here’s the code:R code7.29# make a plot window with three panels in a single rowpar(mfrow=c(1,3)) # 1 row, 3 columns# loop over values of water.c and plot predictionsfor ( w in -1:1 ) {dt

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

Saved successfully!

Ooh no, something went wrong!