08745394 plotsalesdatadvertsalesdatsales x

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 504670 [2,] 2.51478201 [3,] -0.08745394 > > > > > plot(sales.dat$Advert,sales.dat$Sales) x = seq(0,16,by=0.01) y = sales.fit$coeff[1]+sales.fit$coeff[2]*x+sales.fit$coeff[3]*x^2 lines(x,y) abline(lm(Sales~Advert,data=sales.dat),lty=2) > speed MPG Speed 1 4.8 10 2 5.7 10 3 8.6 15 4 7.3 15 5 9.8 20 6 11.2 20 7 13.7 25 8 12.4 25 9 18.2 30 10 16.8 30 11 19.9 35 12 19.0 35 13 22.4 40 14 23.5 40 15 21.3 45 16 22.0 45 17 20.5 50 18 19.7 50 19 18.6 55 20 19.3 55 21 14.4 60 22 13.7 60 23 12.1 65 24 13.0 65 25 10.1 70 26 9.4 70 27 8.4 75 28 7.6 75 > attach(speed) > plot(Speed, MPG) > fit = lm(MPG ~ Speed + I(Speed^2)) > summary(fit) Call: lm(formula = MPG ~ Speed + I(Speed^2)) Residuals: Min 1Q -2.841126 -0.969354 Median 0.001676 3Q 1.018149 Max 3.390000 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -7.5555495 1.4241091 -5.305 1.69e-05 *** Speed 1.2716937 0.0757321 16.792 3.99e-15 *** I(Speed^2) -0.0145014 0.0008719 -16.633 4.97e-15 *** --Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.663 on 25 degrees of freedom Multiple R-Squared: 0.9188, Adjusted R-squared: 0.9123 F-statistic: 141.5 on 2 and 25 DF, p-value: 2.338e-14 > X = model.matrix(fit) >X (Intercept) Speed I(Speed^2) 1 1 10 100 2 1 10 100 3 1 15 225 4 1 15 225 5 1 20 400 6 1 20 400 7 1 25 625 8 1 25 625 9 1 30 900 10 1 30 900 11 1 35 1225 12 1 35 1225 13 1 40 1600 14 1 40 1600 15 1 45 2025 16 1 45 2025 17 1 50 2500 18 1 50 2500 19 1 55 3025 20 1 55 3025 21 1 60 3600 22 1 60 3600 23 1 65 4225 24 1 65 4225 25 1 70 4900 26 1 70 4900 27 1 75 5625 28 1 75 5625 attr(,"assign") [1] 0 1 2 > t(X) %*% X (Intercept) Speed I(Speed^2) (Intercept) 28 1190 61950 Speed 1190 61950 3599750...
View Full Document

This note was uploaded on 04/03/2014 for the course STAT 420 taught by Professor Stepanov during the Spring '08 term at University of Illinois, Urbana Champaign.

Ask a homework question - tutors are online