10.07.2015 Views

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

SHOW MORE
SHOW LESS

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

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

<strong>Using</strong> R <strong>for</strong> introductory statistics 324It matches up, although we didn’t fuss with the order.Now to see if an interaction term is warranted:> interaction.plot(Seat, Popcorn, x)‡ See ?xtabs <strong>for</strong> a similar example.Figure 11.8 Interaction plotindicating presence of aninteraction, as lines are not parallelFigure 11.8 seems to show an interaction, as the slopes are not parallel. We can do a<strong>for</strong>mal test with anova().> res.int=1m(x ~ Seat * Popcorn)> res.add=lm(x ~ Seat + Popcorn)> anova(res.int,res.add)Analysis of Variance TableModel 1: x ~ Seat * PopcornModel 2: x ~ Seat + PopcornRes.Df RSS Df Sum of Sq F Pr(>F)1 12 2772 13 638 −1 −361 15.6 0.0019 **The small p-value casts doubt on the null hypothesis model of no interaction. Thesummary() function gives more detailed in<strong>for</strong>mation about the interaction model.> summary(res.int)Call:1m(<strong>for</strong>mula = x ~ Seat * Popcorn)--Coefficients:Estimate Std. Error t value Pr(>|t|)

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

Saved successfully!

Ooh no, something went wrong!