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.

Goodness of fit 257D = 0.0745, p-value = 0.6363...The p-values are significant only when the parameters do not match the knownpopulation ones.■ Example 9.3: Difference in SAT scores The data set stud. recs (<strong>Using</strong>R) containsmath and verbal SAT scores <strong>for</strong> some students (sat.m and sat.v). Assume naively that thetwo samples are independent, are the samples from the same population of scores?First, we make a q-q plot, a side-by-side boxplot, and a plot of the e.c.d.f.’s <strong>for</strong> thedata, to see whether there is any merit to the question.> data(stud.recs,package="<strong>Using</strong>R") # or library(<strong>Using</strong>R)> attach(stud.recs)> boxplot(list(math=sat.m,verbal=sat.v), main="SATscores")> qqplot(sat.m,sat.v, main="Math and verbal SATscores")> plot(ecdf(sat.m), main="Math and verbal SAT scores")> lines(ecdf(sat.v), lty=2)The graphics are in Figure 9.4. The q-q plot shows similarly shaped distributions, butboxplots show that the centers appear to be different. Consequently, the cumulativedistribution functions do not look that similar. The KolmogorovSmirnov test detects thisand returns a small p-value.Figure 9.4 Three plots comparingthe distribution of math and verbalSAT scores in the stud.recs (<strong>Using</strong>R)data set.> ks.test(sat.m,sat.v)Two-sample Kolmogorov-Smirnov testdata: sat.m and sat.v

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

Saved successfully!

Ooh no, something went wrong!