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.

Bivariate data 75interested in comparing their populations. Are the centers the same? The spreads? Dothey have the same shape distribution? In Chapter 7 we use statistical models to helpanswer such questions. In this section, we learn to explore the relationships graphically togain insight into the answers.3.2.1 Side-by-side boxplotsThe stem-and-leaf plot and boxplot were very effective at summarizing a distribution.The stem-and-leaf plot was used when the data set was small; the boxplot can be used onlarger data sets. By putting them side by side or back to back, we can make comparisonsof the two samples.Table 3.6 Weight loss during ephedra trial (inpounds)placebo treatment ephedra treatment42000 0 05 0 6794443 1 13775 1 666782 01Table 3.6 contains hypothetical data on weight loss during a clinical trial of the ephedrasupplement. As mentioned in Example 1.3, ephedra is a popular supplement that was<strong>for</strong>ced off the market due to its side effects.The back-to-back stem-and-leaf plot shows that the ephedra group has a larger center.The question of whether this is “significant” is answered using a t-test, which is coveredin Chapter 8.The stem() function doesn’t make back-to-back stem-and-leaf plots. If the data set istoo large to make a stem-and-leaf plot by hand, side-by-side boxplots are useful <strong>for</strong>highlighting differences. (These are better named parallel boxplots, as they may bedisplayed horizontally or vertically.)The command boxplot(x, y) will create side-by-side boxplots from two variables. Thenames= argument is used to label the boxplots in Figure 3.2. The figure shows slightlydifferent distributions, with, perhaps, similar medians.> pl = c(0, a, a, 2, 4, 5, 14, 14, 14, 13, 17, 17, 15)> ep = c(0, 6, 7, 9, 11, 13, 16, 16, 16, 17, 18, 20,21)> boxplot(pl,ep, names=c("placebo","ephedra"))

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

Saved successfully!

Ooh no, something went wrong!