11.07.2015 Views

[U] User's Guide

[U] User's Guide

[U] User's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

[ U ] 20.9 Obtaining predicted values 271Example 6Let’s perform a linear regression of mpg on weight and the square of weight:. regress mpg weight c.weight#c.weightSource SS df MS Number of obs = 74F( 2, 71) = 72.80Model 1642.52197 2 821.260986 Prob > F = 0.0000Residual 800.937487 71 11.2808097 R-squared = 0.6722Adj R-squared = 0.6630Total 2443.45946 73 33.4720474 Root MSE = 3.3587mpg Coef. Std. Err. t P>|t| [95% Conf. Interval]weight -.0141581 .0038835 -3.65 0.001 -.0219016 -.0064145c.weight#c.weight 1.32e-06 6.26e-07 2.12 0.038 7.67e-08 2.57e-06_cons 51.18308 5.767884 8.87 0.000 39.68225 62.68392After the regression, predict is defined to be−.0141581weight + 1.32 · 10 −6 weight 2 + 51.18308(Actually, it is more precise because the coefficients are internally stored at much higher precision thanshown in the output.) Thus we can create a new variable—call it fitted—equal to the predictionby typing predict fitted and then use scatter to display the fitted and actual values separatelyfor domestic and foreign automobiles:. predict fitted(option xb assumed; fitted values). scatter mpg fitted weight, by(foreign, total) c(. l) m(o i) sortDomesticForeign10 20 30 402,000 3,000 4,000 5,000Total10 20 30 402,000 3,000 4,000 5,000Weight (lbs.)Mileage (mpg)Fitted valuesGraphs by Car typepredict can calculate much more than just predicted values. For predict after linear regression,predict can calculate residuals, standardized residuals, studentized residuals, influence statistics, etc.In any case, we specify what is to be calculated via an option, so if we wanted the residuals storedin new variable r, we would type. predict r, resid

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

Saved successfully!

Ooh no, something went wrong!