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.

Analysis of variance 313> ewr.out=subset(ewr, subset=inorout=="out”,select=3:10)> out=stack(ewr.out)> names(out)=c("time","airline”)> levels(out$airline)[1] “AA" “CO" “DL" “HP" “NW" “TW" “UA" “US"In modeling, the reference level comes from the first level reported by the levels()function. This is AA, or American Airlines.Figure 11.5 Boxplots and plots ofconfidence intervals given by theTukey procedure <strong>for</strong> time it takes totakeoff at Newark Liberty airportby airlineNow plot (the boxplots in Figure 11.5) and fit the linear model as follows:> plot(time ~ airline, data=out)> res=lm(time ~ airline, data=out)> summary(res)Call:1m(<strong>for</strong>mula=time ~ airline, data=out)…Coefficients:Estimate Std. Error t value Pr(>|t|)(Intercept) 27.0565 0.7204 37.56 < 2e−16 ***airlineCO 3.8348 1.0188 3.76 0.00023 ***airlineDL −2.0522 1.0188 −2.01 0.04550 *airlineHP 1.5261 1.0188 1.50 0.13595airlineNW −4.0609 1.0188 −3.99 9.8e−05 ***airlineTW −1.6522 1.0188 −1.62 0.10667airlineUA -0.0391 1.0188 -0 04 0.96941airlineUS -3.8304 1.0188 -3 76 0.00023 ***--

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

Saved successfully!

Ooh no, something went wrong!