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

Create successful ePaper yourself

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

Analysis of variance 31511.11 The Traffic (MASS) data set contains data on road deaths in Sweden during1961 and 1962. An investigation into the effect of an en<strong>for</strong>ced speed limit on the numberof traffic fatalities was conducted. The y variable contains the number of deaths <strong>for</strong> agiven day, the year variable is the year of the data, and limit is a factor indicating whenthe speed limit was en<strong>for</strong>ced.Use lm () to per<strong>for</strong>m a t-test to investigate whether the year has an effect on thenumber of deaths. Repeat to test whether the variable limit has an effect.11.12 For the data in Table 11.4, per<strong>for</strong>m the one-way ANOVA using lm(). Compareto the results of oneway.test().11.13 For the mt cars data set, per<strong>for</strong>m a one-way analysis of variance of the responsevariable mpg modeled by cyl, the number of cylinders. Use factor(), as cyl is stored as anumeric variable.11.14 The data set npdb (<strong>Using</strong>R) contains malpractice award in<strong>for</strong>mation. Thevariable amount contains the amount of a settlement, and the variable year contains theyear of the award. We wish to investigate whether the dollar amount awarded was steadyduring the years 2000, 2001, and 2002.1. Make boxplots of amount broken up by year. Why is the data not suitable <strong>for</strong> a onewayanalysis of variance?2. Make boxplots of log (amount) broken up by year. Is this data suitable <strong>for</strong> a onewayanalysis of variance?3. Per<strong>for</strong>m an analysis of variance of log (amount) by factor (year) <strong>for</strong> the years 2000,2001, and 2002. Is the null hypothesis of no difference in mean award amount reasonablegiven this data?11.15 For the mtcars data set, per<strong>for</strong>m a one-way analysis of variance of the responsevariable mpg modeled by am, which is a <strong>for</strong> automatic and 1 <strong>for</strong> manual. Use factor(), asam is stored as a numeric variable.11.16 Per<strong>for</strong>m the Tukey procedure on the data set morley after modeling Speed byexpt. Which differences are significant? Do they include all the ones flagged by themarginal t-tests returned by lm() on the same model?11.17 The car safety (<strong>Using</strong>R) data set shows a difference in means through ananalysis of variance when the variable Other. deaths is modeled by type. Per<strong>for</strong>m theTukey HSD method to see what pairwise differences are flagged at a 95% confidencelevel. What do you conclude?11.18 The InsectSprays data set contains a variable count, which counts the number ofinsects and a factor spray, which indicates the treatment given.First per<strong>for</strong>m an analysis of variance to see whether the treatments make a difference.If so, per<strong>for</strong>m the Tukey HSD procedure to see which pairwise treatments differ.

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

Saved successfully!

Ooh no, something went wrong!