





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Number of cylinders
Engine displacement
Horsepower
Acceleration
Price (?)
. regress mpg cylinder
Source | SS df MS Number of obs = 154 -------------+------------------------------ F( 1, 152) = 126. Model | 3788.24488 1 3788.24488 Prob > F = 0. Residual | 4538.50863 152 29.8586094 R-squared = 0. -------------+------------------------------ Adj R-squared = 0. Total | 8326.75351 153 54.4232255 Root MSE = 5.
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- cylinder | -3.637801 .3229644 -11.26 0.000 -4.275879 -2. _cons | 46.41558 1.625274 28.56 0.000 43.20454 49.
. regress mpg displace
Source | SS df MS Number of obs = 154 -------------+------------------------------ F( 1, 152) = 201. Model | 4743.50777 1 4743.50777 Prob > F = 0. Residual | 3583.24573 152 23.5739851 R-squared = 0. -------------+------------------------------ Adj R-squared = 0. Total | 8326.75351 153 54.4232255 Root MSE = 4.
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- displace | -.0765923 .0053995 -14.19 0.000 -.0872601 -. _cons | 40.56734 .9176048 44.21 0.000 38.75444 42.
. regress mpg horsepow
Source | SS df MS Number of obs = 150 -------------+------------------------------ F( 1, 148) = 243. Model | 5030.94725 1 5030.94725 Prob > F = 0. Residual | 3055.82715 148 20.6474807 R-squared = 0. -------------+------------------------------ Adj R-squared = 0. Total | 8086.7744 149 54.2736537 Root MSE = 4.
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- horsepow | -.237707 .0152283 -15.61 0.000 -.2677999 -. _cons | 49.87064 1.403124 35.54 0.000 47.0979 52.
. regress mpg accel
Source | SS df MS Number of obs = 154 -------------+------------------------------ F( 1, 152) = 8. Model | 429.143083 1 429.143083 Prob > F = 0. Residual | 7897.61042 152 51.9579633 R-squared = 0. -------------+------------------------------ Adj R-squared = 0. Total | 8326.75351 153 54.4232255 Root MSE = 7.
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- accel | .6626446 .2305715 2.87 0.005 .2071058 1. _cons | 18.00445 3.798794 4.74 0.000 10.49919 25.
. regress mpg price
Source | SS df MS Number of obs = 154 -------------+------------------------------ F( 1, 152) = 0. Model | .007485901 1 .007485901 Prob > F = 0. Residual | 8326.74602 152 54.7812238 R-squared = 0. -------------+------------------------------ Adj R-squared = -0. Total | 8326.75351 153 54.4232255 Root MSE = 7.
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- price | -3.47e-06 .0002971 -0.01 0.991 -.0005905. _cons | 28.80952 1.49389 19.28 0.000 25.85805 31.
MPG = β 0 + β 1 i wgt + β 2 i cyl + β 3 i displ + β 4 i hp + β 5 i accel +ε
ε
. regress mpg weight cylinder displace horsepow accel
Source | SS df MS Number of obs = 150 -------------+------------------------------ F( 5, 144) = 79. Model | 5943.51201 5 1188.7024 Prob > F = 0. Residual | 2143.26239 144 14.8837666 R-squared = 0. -------------+------------------------------ Adj R-squared = 0. Total | 8086.7744 149 54.2736537 Root MSE = 3.
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- weight | -.0101399 .0017803 -5.70 0.000 -.0136589 -. cylinder | .2859285 .6469444 0.44 0.659 -.9928057 1. displace | .0182705 .0173536 1.05 0.294 -.0160301. horsepow | -.0733252 .0355269 -2.06 0.041 -.1435468 -. accel | .3602982 .2056064 1.75 0.082 -.0460983. _cons | 52.32295 3.970578 13.18 0.000 44.4748 60.
. correlate cylinder displace horsepow accel weight (obs=150)
| cylinder displace horsepow accel weight -------------+--------------------------------------------- cylinder | 1. displace | 0.9318 1. horsepow | 0.7779 0.8226 1. accel | -0.2101 -0.2066 -0.4929 1. weight | 0.8300 0.9150 0.8107 -0.0478 1.
. regress mpg weight cylinder displace horsepow accel , beta
Source | SS df MS Number of obs = 150 -------------+------------------------------ F( 5, 144) = 79. Model | 5943.51201 5 1188.7024 Prob > F = 0. Residual | 2143.26239 144 14.8837666 R-squared = 0. -------------+------------------------------ Adj R-squared = 0. Total | 8086.7744 149 54.2736537 Root MSE = 3.
mpg | Coef. Std. Err. t P>|t| Beta -------------+---------------------------------------------------------------- weight | -.0101399 .0017803 -5.70 0.000 -. cylinder | .2859285 .6469444 0.44 0.659. displace | .0182705 .0173536 1.05 0.294. horsepow | -.0733252 .0355269 -2.06 0.041 -. accel | .3602982 .2056064 1.75 0.082. _cons | 52.32295 3.970578 13.18 0..
. regress mpg cylinder displace horsepow accel year weight price, beta (Gasana) Source | SS df MS Number of obs = 150 -------------+------------------------------ F( 7, 142) = 68. Model | 6247.30769 7 892.472528 Prob > F = 0. Residual | 1839.46671 142 12.9539909 R-squared = 0. -------------+------------------------------ Adj R-squared = 0. Total | 8086.7744 149 54.2736537 Root MSE = 3.
mpg | Coef. Std. Err. t P>|t| Beta -------------+---------------------------------------------------------------- cylinder | .4368451 .6167177 0.71 0.480. displace | .0287842 .0170537 1.69 0.094. horsepow | -.0554725 .0333758 -1.66 0.099 -. accel | .431885 .193399 2.23 0.027. year | .2809669 .2709474 1.04 0.302. weight | -.0123731 .0018463 -6.70 0.000 -1. price | .0006226 .000195 3.19 0.002. _cons | 27.85781 22.5288 1.24 0..
. regress mpg weight cylinder displace horsepow accel , beta (Turchi) Source | SS df MS Number of obs = 150 -------------+------------------------------ F( 5, 144) = 79. Model | 5943.51201 5 1188.7024 Prob > F = 0. Residual | 2143.26239 144 14.8837666 R-squared = 0. -------------+------------------------------ Adj R-squared = 0. Total | 8086.7744 149 54.2736537 Root MSE = 3.
mpg | Coef. Std. Err. t P>|t| Beta -------------+---------------------------------------------------------------- weight | -.0101399 .0017803 -5.70 0.000 -. cylinder | .2859285 .6469444 0.44 0.659. displace | .0182705 .0173536 1.05 0.294. horsepow | -.0733252 .0355269 -2.06 0.041 -. accel | .3602982 .2056064 1.75 0.082. _cons | 52.32295 3.970578 13.18 0..
**1. Inclusion of price makes acceleration significant
Handout: Multiple Regression Analysis of Mileage Data
. regress mpg cylinder displace horsepow accel year weight price, beta (Gasana)
Source | SS df MS Number of obs = 150 -------------+------------------------------ F( 7, 142) = 68. Model | 6247.30769 7 892.472528 Prob > F = 0. Residual | 1839.46671 142 12.9539909 R-squared = 0. -------------+------------------------------ Adj R-squared = 0. Total | 8086.7744 149 54.2736537 Root MSE = 3.
mpg | Coef. Std. Err. t P>|t| Beta -------------+---------------------------------------------------------------- cylinder | .4368451 .6167177 0.71 0.480. displace | .0287842 .0170537 1.69 0.094. horsepow | -.0554725 .0333758 -1.66 0.099 -. accel | .431885 .193399 2.23 0.027. year | .2809669 .2709474 1.04 0.302. weight | -.0123731 .0018463 -6.70 0.000 -1. price | .0006226 .000195 3.19 0.002. _cons | 27.85781 22.5288 1.24 0..
ε
*** = sig at 0.000 level ** = sig at 0.041 level
1
βˆ
0
Y ˆ = βˆ^ + βˆ X +βˆ X
1 2 1 2
Fraction
Distribution of final exam scores
(^35 40 45 50 55 60 65) fin 70 75 80 85 90 95 100
0
.
.
.
.
.
graph fin, bin(13) xlabel(35 40 to 100) ylabel(0 .05 to .25) ti("Distribution of final exam scores")
. summarize fin, detail fin
Percentiles Smallest 1% 39 37 5% 49 38 10% 54 39 Obs 335 25% 64 39 Sum of Wgt. 335 50% 71 Mean 70. Largest Std. Dev. 11. 75% 78 92 90% 85 93 Variance 133. 95% 88 93 Skewness -. 99% 92 94 Kurtosis 3. . describe
Contains data from D:\Amifiles\Econ 70\lectures_new\MultReg_Ec10.dta obs: 344 Economics 10 Data vars: 6 17 Apr 2003 17: size: 16,512 (98.4% of memory free)
storage display value variable name type format label variable label
mtm1 double %12.0g First Midterm Score mtm2 double %12.0g Second Midterm Score mtm3 double %12.0g Third Midterm Score tag double %12.0g TA grade fin double %12.0g Final Exam Score id float %9.0g Student ID
Sorted by: mtm
Grid lines are 5, 10, 25, 50, 75, 90, and 95 percentiles
Final Exam Score
Inverse Normal 38.4455 102.
51.2406 70.2776 89.
37
49
71
88
. regress fin mtm1 mtm2 mtm3 tag
Source | SS df MS Number of obs = 331 -------------+------------------------------ F( 4, 326) = 155. Model | 29172.9861 4 7293.24652 Prob > F = 0. Residual | 15328.4037 326 47.0196431 R-squared = 0. -------------+------------------------------ Adj R-squared = 0. Total | 44501.3897 330 134.852696 Root MSE = 6.
fin | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- mtm1 | .227831 .0463552 4.91 0.000 .1366379. mtm2 | .2044693 .0395619 5.17 0.000 .1266404. mtm3 | .4081122 .0370606 11.01 0.000 .335204. tag | .016204 .056534 0.29 0.775 -.0950135. _cons | 7.930885 5.164574 1.54 0.126 -2.229214 18.
Grid lines are 5, 10, 25, 50, 75, 90, and 95 percentiles
Residual
Inverse Normal
-11.2103 -1.2e-08 11.
Residual
Residuals vs. Expected Value of Final Exam Score
Fitted values 42.4855 90.
-24.
Residual
Residuals vs. Third Midterm Score
Third Midterm Score
23 100
-24.
m
m
ˆ ˆ ˆ ˆ ˆ 1 2 3
7.93 0.228 1 0.204 2 0.408 3 0.
fin mtm mtm mtm tag
fin mtm mtm mtm tag
= β + β + β + β +β
= + + + +
i i i i
i i i i
R =0.
Residual
Fitted values
Stem-and-leaf plot for fin (Final Exam Score)
3s | 7
Reject Ho
z α = 3.
p = 0.
(20 feet) (100 feet)
Minimum Distance
Mean Distance
(2,641 feet) Maximum Distance
Natural Log of Chloride Concentration(mg per liter)
. regress lnchlor deep lndroad deeproad
Source | SS df MS Number of obs = 52 -------------+------------------------------ F( 3, 48) = 3. Model | 18.4831272 3 6.1610424 Prob > F = 0. Residual | 77.5390714 48 1.61539732 R-squared = 0. -------------+------------------------------ Adj R-squared = 0. Total | 96.0221986 51 1.88278821 Root MSE = 1.
lnchlor | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- deep | -6.717366 2.094713 -3.21 0.002 -10.92907 -2. lndroad | -1.109424 .3844204 -2.89 0.006 -1.882354 -. deeproad | 1.255847 .4268777 2.94 0.005 .3975521 2. _cons | 9.073459 1.879384 4.83 0.000 5.294704 12.
Chloride Concentrations and Distance*
Natural Log of Distance (in feet)
0 2 4 6 8
0
2
4
6
8
10
(20 feet) (100 feet)
Minimum Distance
Mean Distance
(2,641 feet) Maximum Distance
Shallow Wells Deep Wells
Natural Log of Chloride Concentration (mgper liter)
*Closest well is 20 feet, furthest is 2,641 feet
Handout on using
dummy variables to
test interaction effects
in regression analysis
MPG = β 0 +β 1 i wgt +β 2 i cyl + β 3 i displ +β 4 i hp +β 5 i accel + β 6 i year +β 7 i price +β 8 i wgt × hp +ε
. regress mpg weight cylinder displace horsepow accel year price
Source | SS df MS Number of obs = 150 -------------+------------------------------ F( 7, 142) = 68. Model | 6247.30769 7 892.472528 Prob > F = 0. Residual | 1839.46671 142 12.9539909 R-squared = 0. -------------+------------------------------ Adj R-squared = 0. Total | 8086.7744 149 54.2736537 Root MSE = 3.
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- weight | -.0123731 .0018463 -6.70 0.000 -.0160229 -. cylinder | .4368451 .6167177 0.71 0.480 -.7822891 1. displace | .0287842 .0170537 1.69 0.094 -.0049278. horsepow | -.0554725 .0333758 -1.66 0.099 -.1214501. accel | .431885 .193399 2.23 0.027 .0495716. year | .2809669 .2709474 1.04 0.302 -.2546449. price | .0006226 .000195 3.19 0.002 .0002371. _cons | 27.85781 22.5288 1.24 0.218 -16.67736 72.
ε
β 1
β 2
β 3
β 4 β 5
β 8
β 6
β
. regress mpg weight cylinder displace horsepow accel year price wthp
Source | SS df MS Number of obs = 150 -------------+------------------------------ F( 8, 141) = 66. Model | 6394.74812 8 799.343515 Prob > F = 0. Residual | 1692.02628 141 12.0001864 R-squared = 0. -------------+------------------------------ Adj R-squared = 0. Total | 8086.7744 149 54.2736537 Root MSE = 3.
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- weight | -.0167031 .0021642 -7.72 0.000 -.0209816 -. cylinder | .0609603 .603188 0.10 0.920 -1.131501 1. displace | .0156661 .0168351 0.93 0.354 -.0176157. horsepow | -.2849999 .0729368 -3.91 0.000 -.429191 -. accel | .3059297 .1895796 1.61 0.109 -.0688561. year | .3410433 .2613443 1.30 0.194 -.1756165. price | .000649 .0001878 3.45 0.001 .0002776. wthp | .0000745 .0000212 3.51 0.001 .0000325. _cons | 42.22624 22.0676 1.91 0.058 -1.399893 85.
MPG hp wgt
β β
∂ = + ∂
i
1 8 0.0167^ 0.
MPG hp hp wgt
β β
∂ = + = − + × ∂
i
β β
β β
β β
weight | -.0123731 -6.70 -.0167031 -7. cylinder | .4368451 0.71 .0609603 0. displace | .0287842 1.69 .0156661 0. horsepow | -.0554725 -1.66 -.2849999 -3. accel | .431885 2.23 .3059297 1. year | .2809669 1.04 .3410433 1. price | .0006226 3.19 .000649 3. wthp | -------------- .0000745 3. _cons | 27.85781 1.24 42.22624 1.*
1 8
hp wgt β β
i
The marginal impact of a one pound change in a car's weight depends on the horsepower of the engine in the car.
hp hp wgt
β β
i
wgt wgt hp β β
i
No Interaction With Interaction Coef. t Coef. t
. regress mpg weight cylinder displace horsepow accel year price Source | SS df MS Number of obs = 150 -------------+------------------------------ F( 7, 142) = 68. Model | 6247.30769 7 892.472528 Prob > F = 0. Residual | 1839.46671 142 12.9539909 R-squared = 0. -------------+------------------------------ Adj R-squared = 0. Total | 8086.7744 149 54.2736537 Root MSE = 3.
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- weight | -.0123731 .0018463 -6.70 0.000 -.0160229 -. cylinder | .4368451 .6167177 0.71 0.480 -.7822891 1. displace | .0287842 .0170537 1.69 0.094 -.0049278. horsepow | -.0554725 .0333758 -1.66 0.099 -.1214501. accel | .431885 .193399 2.23 0.027 .0495716. year | .2809669 .2709474 1.04 0.302 -.2546449. price | .0006226 .000195 3.19 0.002 .0002371. _cons | 27.85781 22.5288 1.24 0.218 -16.67736 72.
. regress mpg weight cylinder displace horsepow accel year price wthp
Source | SS df MS Number of obs = 150 -------------+------------------------------ F( 8, 141) = 66. Model | 6394.74812 8 799.343515 Prob > F = 0. Residual | 1692.02628 141 12.0001864 R-squared = 0. -------------+------------------------------ Adj R-squared = 0. Total | 8086.7744 149 54.2736537 Root MSE = 3.
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- weight | -.0167031 .0021642 -7.72 0.000 -.0209816 -. cylinder | .0609603 .603188 0.10 0.920 -1.131501 1. displace | .0156661 .0168351 0.93 0.354 -.0176157. horsepow | -.2849999 .0729368 -3.91 0.000 -.429191 -. accel | .3059297 .1895796 1.61 0.109 -.0688561. year | .3410433 .2613443 1.30 0.194 -.1756165. price | .000649 .0001878 3.45 0.001 .0002776. wthp | .0000745 .0000212 3.51 0.001 .0000325. _cons | 42.22624 22.0676 1.91 0.058 -1.399893 85.
weight | -.0123731 -6.70 -.0167031 -7. cylinder | .4368451 0.71 .0609603 0. displace | .0287842 1.69 .0156661 0. horsepow | -.0554725 -1.66 -.2849999 -3. accel | .431885 2.23 .3059297 1. year | .2809669 1.04 .3410433 1. price | .0006226 3.19 .000649 3. wthp | -------------- .0000745 3. _cons | 27.85781 1.24 42.22624 1.*
β 1
2 2 1 2 0 1 1 1 1
n n n K i i i k ik i i i k
−
= = = =
( 1) cylinder - displace = 0 ( 2) cylinder - accel = 0 ( 3) cylinder - year = 0 ( 4) cylinder = 0
0
5
10
Regression Residuals
15 20 25 30 35 40 Fitted values
Regression Residuals
-5.542908 -6.73e-08 5.
Inverse Normal Grid lines are 5, 10, 25, 50, 75, 90, and 95 percentiles