Docsity

Class Notes for Elementary Statistics | ECON 400, Study notes of Economic statistics

Toggle sidebar
bg1
The Course So Far:
Descriptive
Statistics Probability
Theory Probability
Distributions Simple Random
Sampling
Sampling
Distributions
Statistical
Inference
Multiple
Regression
Regression &
Correlation
Estimation Hypothesis
Tes ti ng
Number of cylinders
Engine displacement
Horsepower
Acceleration
Price (?)
# of cyl MPG
. regress mpg cylinder
Source | SS df MS Numbe r of obs = 154
-------------+------------------------------ F( 1 , 152) = 126.87
Model | 3788.24488 1 3788.24488 Prob > F = 0.0000
Residual | 4538.50863 152 29.8586094 R-squ ared = 0.4549
-------------+------------------------------ Adj R -squared = 0.4514
Total | 8326.75351 153 54.4232255 Root MSE = 5.4643
------------------------------------------------------------ ------------------
mpg | Coef. Std. Err. t P>|t| [9 5% Conf. Interval]
-------------+---------------------------------------------- ------------------
cylinder | -3.637801 .3229644 -11.26 0.000 -4. 275879 -2.999722
_cons | 46.41558 1.625274 28.56 0.000 43 .20454 49.62662
------------------------------------------------------------ ------------------
. regress mpg displace
Source | SS df MS Num ber of obs = 154
-------------+------------------------------ F( 1, 152) = 201.22
Model | 4743.50777 1 4743.50777 Pro b > F = 0.0000
Residual | 3583.24573 152 23.5739851 R-s quared = 0.5697
-------------+------------------------------ Adj R-squared = 0.5668
Total | 8326.75351 153 54.4232255 Roo t MSE = 4.8553
---------------------------------------------------------- --------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+-------------------------------------------- --------------------
displace | -.0765923 .0053995 -14.19 0.000 - .0872601 -.0659246
_cons | 40.56734 .9176048 44.21 0.000 38.75444 42.38025
---------------------------------------------------------- --------------------
. regress mpg horsepow
Source | SS df MS Num ber of obs = 150
-------------+------------------------------ F( 1, 148) = 243.66
Model | 5030.94725 1 5030.94725 Pro b > F = 0.0000
Residual | 3055.82715 148 20.6474807 R-s quared = 0.6221
-------------+------------------------------ Adj R-squared = 0.6196
Total | 8086.7744 149 54.2736537 Roo t MSE = 4.5439
---------------------------------------------------------- --------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+-------------------------------------------- --------------------
horsepow | -.237707 .0152283 -15.61 0.000 - .2677999 -.207614
_cons | 49.87064 1.403124 35.54 0.000 47.0979 52.64339
---------------------------------------------------------- --------------------
. regress mpg accel
Source | SS df MS Number of obs = 154
-------------+------------------------ ------ F( 1, 152) = 8.26
Model | 429.143083 1 429. 143083 Prob > F = 0.0046
Residual | 7897.61042 152 51.9579633 R-squared = 0.0515
-------------+------------------------ ------ Adj R-squared = 0.0453
Total | 8326.75351 153 54.4232255 Root MSE = 7.2082
-------------------------------------- ----------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+------------------------ ----------------------------------------
accel | .6626446 .2305715 2.87 0.005 .2071058 1.118183
_cons | 18.00445 3.798794 4.74 0.000 10.49919 25.5097
-------------------------------------- ----------------------------------------
. regress mpg price
Source | SS df MS Number of obs = 154
-------------+----------------------- ------- F( 1, 152) = 0.00
Model | .007485901 1 .00 7485901 Prob > F = 0.9907
Residual | 8326.74602 152 54.7812238 R-squared = 0.0000
-------------+----------------------- ------- Adj R-squared = -0.0066
Total | 8326.75351 153 54.4232255 Root MSE = 7.4014
------------------------------------- -----------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------- -----------------------------------------
price | -3.47e-06 .0002971 -0.01 0.991 -.0005905 .0005836
_cons | 28.80952 1.49389 19.28 0.000 25.85805 31.76099
------------------------------------- -----------------------------------------
Regression Coefficient (t-statistic), R-squared
Weight -.0101428 (-18.28) R-square = 0.6874
Cylinders -3.637801 ( -11.26) R-square = 0.4549
Displacement -.0765923 ( -14.19) R-square = 0.5697
Horsepower -.237707 ( -15.61) R-square = 0.6221
Acceleration .6626446 (2.87) R-square = 0.0515
01 2 3 4 5
MPG wgt cyl displ hp accel
ββ β β β β ε
=+ + + + + +iii ii
# of cyl
MPG
weight
hp accel
displ
ε
. regress mpg weight cylinder displace horsepow accel
Source | SS df MS Number of obs = 150
-------------+------------------------ ------ F( 5, 144) = 79.87
Model | 5943.51201 5 118 8.7024 Prob > F = 0.0000
Residual | 2143.26239 144 14.8 837666 R-squared = 0.7350
-------------+------------------------ ------ Adj R-squared = 0.7258
Total | 8086.7744 149 54.2 736537 Root MSE = 3.8579
-------------------------------------- ----------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+------------------------ ----------------------------------------
weight | -.0101399 .0017803 -5.70 0.000 -.0136589 -.0066209
cylinder | .2859285 .6469444 0.44 0.659 -.9928057 1.564663
displace | .0182705 .0173536 1.05 0.294 -.0160301 .0525712
horsepow | -.0733252 .0355269 -2.06 0.041 -.1435468 -.0031036
accel | .3602982 .2056064 1.75 0.082 -.0460983 .7666947
_cons | 52.32295 3.970578 13.18 0.000 44.4748 60.17109
-------------------------------------- ----------------------------------------
. correlate cylinder displace horsepow accel weight
(obs=150)
| cylinder displace horsep ow accel weight
-------------+------------------------- --------------------
cylinder | 1.0000
displace | 0.9318 1.0000
horsepow | 0.7779 0.8226 1.00 00
accel | -0.2101 -0.2066 -0.49 29 1.0000
weight | 0.8300 0.9150 0.81 07 -0.0478 1.0000
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Class Notes for Elementary Statistics | ECON 400 and more Study notes Economic statistics in PDF only on Docsity!

The Course So Far:

Descriptive

Statistics

Probability

Theory

Probability

Distributions

Simple Random

Sampling

Sampling

Distributions

Statistical

Inference

Multiple

Regression

Regression &

Correlation

Estimation

Hypothesis

Testing

Number of cylinders

Engine displacement

Horsepower

Acceleration

Price (?)

# of cyl MPG

. 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.


Regression Coefficient (t-statistic), R-squared

Weight -.0101428 (-18.28) R-square = 0.

Cylinders -3.637801 ( -11.26) R-square = 0.

Displacement -.0765923 ( -14.19) R-square = 0.

Horsepower -.237707 ( -15.61) R-square = 0.

Acceleration .6626446 (2.87) R-square = 0.

MPG = β 0 + β 1 i wgt + β 2 i cyl + β 3 i displ + β 4 i hp + β 5 i accel +ε

# of cyl

MPG

weight

hp

accel

displ

ε

. 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..


Standardized regression

coefficients show relative

importance of each inde-

pendent variable

. 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

  1. R-square rises
  2. Engine displacement's relative effect rises**

4. Price is now signifi-

cant unlike the bivariate

regression!

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..


Regression Simple Regression Coefficient

(all significant except for price)

Multiple Regression Coefficient

Weight -.010 -.012***

Cylinders -3.63 0.

Displacement -.076 0.03*

Horsepower -.23 -.055*

Acceleration .66 0.43**

Year 2.122 0.

Price -3.47e-06 .00062***

# of cyl

MPG

weight

hp

accel

displ

ε

Multiple regression is

required when relevant

explanatory variables

are correlated with

each other.

*** = sig at 0.000 level ** = sig at 0.041 level

Year

Price

General Rule: Use multiple regression when a number of variables

have an effect on a dependent variable and those variables are

correlated with each other, such that leaving one of them out of the

regression leads to the included variables' coefficients reflecting

some of the excluded variable's influences.

X 1

X 2

Y

Above the plane

Below the plane

In the plane

1

βˆ

0

Fitting a multiple regression plane

through a 3-dimensional scatter plot

Y ˆ = βˆ^ + βˆ X +βˆ X

1 2 1 2

ˆ and ˆ

Y Y

X X

Definition: A statistical analysis is internally valid if the statistical

inferences about causal effects are valid for the population being studied.

The analysis is externally valid if its inferences and conclusions can be

generalized from the population and setting studied to other populations

and settings.

Internal validity has two components:

The estimator of the causal effect should be unbiased and consistent. That is, a slope

coefficient should be an unbiased and consistent estimator of the true population

effect, That is,

β i

E β i β

Hypothesis tests should have the desired significance level (the actual rejection rate of

the test under the null hypothesis should equal its desired significance level).

So, for OLS regression internal validity requires that the OLS estimator is unbiased

and consistent and that standard errors are computed in a way that makes

confidence intervals have the desired confidence level.

Y = β 0 + β 1 X 1 + β 2 X 2 + "+ β k Xk +ε

is a random error, that, for any given set of values of indepent

variables is normally distributed with mean zero and

variance equal to

X 1 , X 2 , X 3 …

The random errors, and associated with any pair of y- values

are independent of each other and independent of the values of

x- variables included in the model.

j

k

Then, it follows that: [ ]

E Y = β 0 + β 1 X 1 + β 2 X 2 + "+β k Xk

The model is "well specified", i.e., all relevant (and correlated) explantory

variables are included in the model.

The Problem: Does performance on midterm exams predict

performance on the final exam very well? Do different midterms have a

different impact on final exam performance?

Final

Exam

Score

MTM

Score

MTM

Score

MTM

Score

TA Grade

fin = β + βi mtm 1 + βi mtm 2 + βi mtm 3 + β i tag +ε

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

qnorm fin, grid

. 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.


qnorm epsilon, grid

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.

gr epsilon finhat, two box yline(0)

ti("Residuals vs. Expected Value of Final

Exam Score")

Residual

Residuals vs. Third Midterm Score

Third Midterm Score

23 100

-24.

gr epsilon mtm3, two box

yline(0) ti("Residuals vs. Third

Midterm Score")

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.

Final

Exam

Score

MTM

Score

MTM

Score

MTM

Score

TA Grade

(* = significant at

the 5 % level at a

minimum)

Residual

Residuals vs. Expected Value of Final Exam Score

Fitted values

gr epsilon finhat, two box yline(0)

ti("Residuals vs. Expected Value of

Final Exam Score") xlabel(37 42 to 92)

ylabel(-25 -20 to 30)

Stem-and-leaf plot for fin (Final Exam Score)

3s | 7

  1. | 89999 4* | 1 4t | 2223 4f | 4 4s | 7777
  2. | 9 5* | 0001111 5t | 2222333 5f | 44445555 5s | 6677
  3. | 888888888889 6* | 001111111 6t | 2222222223333333 6f | 444444555555555555555 6s | 666666666666777777777777
  4. | 88888889999999 7* | 00000000000000001111111111111111111 7t | 2222222222333333333333 7f | 444444444444444455555555 7s | 6666666666777777777777
  5. | 888888888888999999999999 8* | 000000011111111111 8t | 22222222223333 8f | 4445555 8s | 66667777
  6. | 88888899999 9* | 0000011 9t | 233 9f | 4

x

z

Reject Ho

z α = 3.

p = 0.

The probability of getting a residual

this large is approximately one in

ten thousand.

Chloride Concentrations and Distance*

Natural Log of Distance (in feet)

(20 feet) (100 feet)

Minimum Distance

Mean Distance

(2,641 feet) Maximum Distance

Shallow Wells

Deep Wells

Natural Log of Chloride Concentration(mg per liter)

*Closest well is 20 feet, furthest is 2,641 feet

. 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

. generate wthp= weight* horsepow

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.


# of cyl

MPG

weight

hp

accel

displ

ε

wgt xhp

β 1

β 2

β 3

β 4 β 5

β 8

year

price

β 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

The marginal impact of a one pound change in

a car's weight depends on the horsepower of

the engine in the car.

1 8 0.0167^ 0.

MPG hp hp wgt

β β

∂ = + = − + × ∂

i

1 8 0.0167^ 0.0000745^139 0.

MPG

hp

wgt

= + = − + × = −

i

1 8 0.0167^ 0.0000745^60 0.

MPG

hp

wgt

= + = − + × = −

i

4 8 0.285^ 0.

MPG

wgt wgt

hp

β β

= + = − + ×

i

4 8 0.285^ 0.0000745^ 1,875^ 0.

MPG

wgt

hp

β β

= + = − + × = −

i

4 8 0.285^ 0.0000745^ 3,830^ 0.

MPG

wgt

hp

β β

= + = − + × =

i

No Interaction With Interaction

Coef. t Coef. t

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.*

Car Mileage: No Interaction Effect

Car Mileage: With Interaction Effect

1 8

MPG

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.

1 8 0.0167^ 0.
MPG

hp hp wgt

β β

= + = − + ×

i

4 8 0.285^ 0.
MPG

wgt wgt hp β β

= + = − + ×

i

No Interaction With Interaction Coef. t Coef. t

Handout on using metric

variables in testing for

interaction effects in

multiple regression

. 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.*

The Question:

When comparing the total variance explained by the "base model" containing only the

three significant variables to the variance explained by the "expanded model" which

adds the insignificant variables, is the addition to explained variation large enough to

say that this extra set of variables together has significantly raised total explained

variance?

# of cyl

MPG

weight

hp

accel

displ

wgtxhp

β 1

year

price

: at least one of these not equal to zero

a

H

H

Remember, it's RSS that least squares regression seeks to minimize.

Residual Sum of Squares (RSS) is the sum of squared deviations of

the residuals around their mean value of zero:

2 2 1 2 0 1 1 1 1

n n n K i i i k ik i i i k

RSS K ε Y Y Y β β X

−

= = = =

⎝ ⎣^ ⎦⎠

( {^ }^ {^ })

H

n K

RSS K H RSS K H

F

RSS K n K

( 1) cylinder - displace = 0 ( 2) cylinder - accel = 0 ( 3) cylinder - year = 0 ( 4) cylinder = 0

F( 4, 141) = 1.

Prob > F = 0.2049 }

0 :^4

a : at least one of these^ not equal to zero

H

H

test horsepow= wthp=

( 1) horsepow - wthp = 0

( 2) horsepow = 0

F( 2, 141) = 7.

Prob > F = 0.

quietly regress mpg weight cylinder displace horsepow accel year

price wthp

. test cylinder= displace= accel= year=

predict mpghat

generate resid = mpg -mpghat

0

5

10

Regression Residuals

15 20 25 30 35 40 Fitted values

Plot of Mileage Residuals vs. Predicted Values

graph twoway scatter resid mpghat, yline(0)

ti("Plot of Mileage Residuals vs. Predicted

Values")

qnorm resid, grid ti(Normal Probability Plot of Regression

Residuals)

Automobile Mileage Data: Residual Plots

Regression Residuals

-5.542908 -6.73e-08 5.

Inverse Normal Grid lines are 5, 10, 25, 50, 75, 90, and 95 percentiles

Normal Probability Plot of Regression Residuals