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.

<strong>Using</strong> R <strong>for</strong> introductory statistics 274<strong>for</strong> comparison, as comparing slopes isn’t applicable <strong>for</strong> multivariate models. The Cook’sdistance is computed by the extractor function cooks. distance ().One of the diagnostic plots produced by plot () will show the Cook’s distance <strong>for</strong> thedata points plotted using spikes. Another way to display this in<strong>for</strong>mation graphically is tomake the size of the points in the scatterplot depend on this distance using the cex=argument. This type of plot is referred to as a bubble plot and is illustrated using theemissions (<strong>Using</strong>R) data set in Figure 10.4. The graphic is made with the followingcommands:> res = lm(C02 ~ perCapita, emissions)> plot(C02 ~ perCapita, emissions,+ cex = 10*sqrt(cooks.distance(res)),+ main = expression( # make subscript on C02in title+ paste("bubble plot of ",CO[2],+ ” emissions by per capita GDP")+ ))The square root of the distances is used, so the area of the points is proportional to theCook’s distance rather than to the radius. (The argument to main= illustrates how to usemathematical notation in the title of a graphic. See the help page ?plotmath <strong>for</strong> details.)For the maximum-heart-rate data, the four diagnostic plots produced by R with thecommand plot (res. mhr) are in Figure 10.5. The par (mf row=c (2,2)) command was usedto make the four graphs appear in one figure. This command sets the number of rows andcolumns in a multi-graphic figure.

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

Saved successfully!

Ooh no, something went wrong!