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.

Significance tests 217> mpg =c(11.4,13.1,14.7,14.7,15.0,15.5,15.6,15.9,16.0,16.8)> xbar = mean(mpg)> s = sd(mpg)> n = length(mpg)> c(xbar, s, n)[1] 14.870 1.572 10.000> SE = s/sqrt(n)> (xbar − 17)/SE[1] −4.285> pt(−4.285, df = 9, lower.tail = T)[1] 0.001017The p-value is very small and discredits the claim of 17 miles per gallon, as thedifference of from 17 is not well explained by sampling variation.The above calculations could be done using t.test () as follows:> t.test(mpg, mu = 17, alt="less")One Sample t-testdata: mpgt = −4.285, df = 9, p-value = 0.001018alternative hypothesis: true mean is less than 1795 percent confidence interval:−Inf 15.78sample estimates:mean of x14.87The output contains the same p-value (up to rounding), plus a bit more in<strong>for</strong>mation,including the observed value of the test statistic, a one-sided confidence interval, and(the estimate <strong>for</strong> µ). ■It is easy to overlook the entire null hypothesis. We assume not only that µ=µ 0 , butalso that the random sample comes from a normally distributed population withunspecified variance. With these assumptions, the test statistic has a known samplingdistribution. The t-statistic is robust to small differences in the assumed normality of thepopulation, but a really skewed population distribution would still be a poor candidate <strong>for</strong>this significance test unless n is large. It is recommended that you plot the data prior todoing any analysis, to ensure that it is appropriate.■ Example 8.5: Rising textbook costs? A college bookstore claims that, on average,a college student will pay $101.75 per class <strong>for</strong> textbooks. A student group investigatesthis claim by randomly selecting ten courses from the course catalog and finding thetextbook costs <strong>for</strong> each. The data collected is140 125 150 124 143 170 125 94 127 53Do a test of significance of H 0 :µ=101.75 against the alternative hypothesis H A :µ>101.75.We assume independence and normality of the data. Once the data is entered, we canuse t.test(), with “greater” <strong>for</strong> the alternative. This gives

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

Saved successfully!

Ooh no, something went wrong!