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 196is a pivotal quantity with standard normal distribution when n 1 and n 2 are large enough.The standard error isZ has an asymptotic normal distribution, as it may be viewed as a sample average minusits expectation divided by its standard error. The central limit theorem then applies.The function prop.test() can do the calculations <strong>for</strong> us. We use it asprop.test(x,n, conf.level=0.95The data is specified in terms of counts, x, and sample sizes, n, using data vectorscontaining two entries. The results will differ slightly from the above description, as prop.test () uses a continuity correction.■ Example 7.8: Comparing poll results In a span of two weeks the same poll istaken. The first time, 1,000 people are interviewed, and 560 agree; the second time, 1,200are interviewed, and 570 agree. Find a 95% confidence interval <strong>for</strong> the difference ofproportions.Rather than do the work by hand, we let prop.test() find a confidence interval.> prop.test(x=c(560,570), n=c(1000,1200),conf.level=0.95)2-sample test <strong>for</strong> equality of proportions withcontinuity correctiondata: c(560, 570) out of c(1000, 1200)X−squ ared=15.44, df=1, p-value=8.53e−05alternati v e hypothe s is: two.si d ed95 percent confidence interval:0.04231 0.12769sample estimates:prop 1 prop 20.560 0.475We see that a 95% confidence interval is (0.04231, 0.12769), which just misses includinga. We conclude that there appears to be a real difference in the population parameters.7.5.2 Difference of meansMany problems involve comparing independent samples to see whether they come fromidentical parent populations. A teacher could compare two sections of the same class tolook <strong>for</strong> differences; a pharmaceutical company could compare the effects of two drugs;or a manufacturer could compare two samples taken at different times to monitor qualitycontrol.Let and be the two samples with sample meansand sample variances and Assume the populations <strong>for</strong> each sample are normally

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

Saved successfully!

Ooh no, something went wrong!