## Verbeek 5ed. Chapter 4 - Heteroskedasticity and Autocorrelation

```----------------------------------------------------------------------------------------------------
name:  SN
log:  \5iexample4_s.smcl
log type:  smcl
opened on:   5 Jun 2020, 20:25:24
. **********************************************
.  * Solomon Negash - Examples
.  * Verbeek(2017). A Giude To Modern Econometrics. 5ed.
.  * STATA Program, version 16.1.

.  * Chapter 4  - Heteroskedasticity and Autocorrelation
. ******************** **** *********************

. * Table 4.1 OLS results linear model

. u "Data/labour2.dta", clear
. reg labor wage output capital

Source |       SS           df       MS      Number of obs   =       569
-------------+----------------------------------   F(3, 565)       =   2716.02
Model |   198943126         3  66314375.3   Prob > F        =    0.0000
Residual |  13795026.5       565  24415.9761   R-squared       =    0.9352
Total |   212738152       568      374539   Root MSE        =    156.26

------------------------------------------------------------------------------
labor |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
wage |  -6.741904   .5014054   -13.45   0.000     -7.72675   -5.757057
output |   15.40047   .3556333    43.30   0.000     14.70194    16.09899
capital |  -4.590491   .2689693   -17.07   0.000    -5.118793   -4.062189
_cons |   287.7186   19.64175    14.65   0.000     249.1388    326.2984
------------------------------------------------------------------------------

. predict u, r
. g u2=u^2
. reg u2 wage output capital

Source |       SS           df       MS      Number of obs   =       569
-------------+----------------------------------   F(3, 565)       =    262.05
Model |  6.9733e+12         3  2.3244e+12   Prob > F        =    0.0000
Residual |  5.0117e+12       565  8.8702e+09   R-squared       =    0.5818
Total |  1.1985e+13       568  2.1100e+10   Root MSE        =     94182

------------------------------------------------------------------------------
u2 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
wage |   228.8569   302.2172     0.76   0.449    -364.7495    822.4632
output |   5362.207   214.3544    25.02   0.000     4941.179    5783.236
capital |  -3543.509   162.1186   -21.86   0.000    -3861.938   -3225.081
_cons |  -22719.51   11838.87    -1.92   0.055    -45973.09    534.0697
------------------------------------------------------------------------------

. * Table 4.3 OLS results loglinear model

. g lnlabor=log(labor)
. g lnwage=log(wage)
. g lnoutput=log(output)
. g lncapital=log(capital)
. reg lnlabor lnwage lnoutput lncapital

Source |       SS           df       MS      Number of obs   =       569
-------------+----------------------------------   F(3, 565)       =   1011.02
Model |  656.747035         3  218.915678   Prob > F        =    0.0000
Residual |  122.338812       565   .21652887   R-squared       =    0.8430
Total |  779.085847       568  1.37163001   Root MSE        =    .46533

------------------------------------------------------------------------------
lnlabor |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lnwage |  -.9277643   .0714046   -12.99   0.000    -1.068015   -.7875133
lnoutput |   .9900474   .0264103    37.49   0.000      .938173    1.041922
lncapital |  -.0036975   .0187697    -0.20   0.844    -.0405644    .0331695
_cons |    6.17729   .2462105    25.09   0.000      5.69369    6.660889
------------------------------------------------------------------------------

. * Table 4.4. Auxiliary regression White test

. predict uh, r
. g uh2=uh^2
. g lnwage2=lnwage^2
. g lnoutput2=lnoutput^2
. g lncapital2=lncapital^2

. reg uh2 lncapital c.lnwage##c.lnoutput c.lnoutput#c.lncapital c.lnwage#c.lncapital lnwage2 lnoutpu
t2 lncapital2

Source |       SS           df       MS      Number of obs   =       569
-------------+----------------------------------   F(9, 559)       =      7.12
Model |  46.3960128         9  5.15511253   Prob > F        =    0.0000
Residual |  404.532757       559  .723672195   R-squared       =    0.1029
Total |   450.92877       568  .793888679   Root MSE        =    .85069

----------------------------------------------------------------------------------------
uh2 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-----------------------+----------------------------------------------------------------
lncapital |   1.142053   .3758217     3.04   0.002     .4038578    1.880248
lnwage |  -1.299008   1.752744    -0.74   0.459    -4.741778    2.143762
lnoutput |  -.9037247   .5598545    -1.61   0.107      -2.0034     .195951
|
c.lnwage#c.lnoutput |   .1380382   .1625628     0.85   0.396    -.1812704    .4573467
|
c.lnoutput#c.lncapital |  -.1916048   .0368665    -5.20   0.000    -.2640187    -.119191
|
c.lnwage#c.lncapital |  -.2517789   .1049671    -2.40   0.017     -.457957   -.0456008
|
lnwage2 |   .1927418   .2589536     0.74   0.457    -.3158992    .7013828
lnoutput2 |   .1381977   .0356469     3.88   0.000     .0681794    .2082159
lncapital2 |   .0895375   .0139874     6.40   0.000     .0620631    .1170118
_cons |   2.544613   3.002783     0.85   0.397    -3.353504     8.44273
----------------------------------------------------------------------------------------

. * Table 4.5 OLS results loglinear model with White standard errors
. reg lnlabor lnwage lnoutput lncapital, r

Linear regression                               Number of obs     =        569
F(3, 565)         =     544.73
Prob > F          =     0.0000
R-squared         =     0.8430
Root MSE          =     .46533

------------------------------------------------------------------------------
|               Robust
lnlabor |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lnwage |  -.9277643   .0866604   -10.71   0.000     -1.09798   -.7575484
lnoutput |   .9900474   .0467902    21.16   0.000     .8981434    1.081951
lncapital |  -.0036975    .037877    -0.10   0.922    -.0780944    .0706995
_cons |    6.17729   .2938869    21.02   0.000     5.600045    6.754534
------------------------------------------------------------------------------

. * Table 4.6 Auxiliary regression multiplicative heteroskedasticity
. g lnuh2=log(uh2)

. reg lnuh2 lnwage lnoutput lncapital, r

Linear regression                               Number of obs     =        569
F(3, 565)         =       4.92
Prob > F          =     0.0022
R-squared         =     0.0245
Root MSE          =     2.2404

------------------------------------------------------------------------------
|               Robust
lnuh2 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lnwage |  -.0610507   .3291281    -0.19   0.853    -.7075147    .5854133
lnoutput |   .2669502   .1378352     1.94   0.053    -.0037818    .5376821
lncapital |  -.3306879   .0910089    -3.63   0.000    -.5094449   -.1519308
_cons |  -3.253832   1.110527    -2.93   0.004    -5.435097   -1.072566
------------------------------------------------------------------------------

. * Table 4.7 EGLS results loglinear model

. predict xb, xb
. g w = 1/(exp(xb))
. reg lnlabor lnwage lnoutput lncapital [weight=w]
(analytic weights assumed)
(sum of wgt is 16,475.1465694904)

Source |       SS           df       MS      Number of obs   =       569
-------------+----------------------------------   F(3, 565)       =   1074.48
Model |  700.868865         3  233.622955   Prob > F        =    0.0000
Residual |  122.847468       565  .217429147   R-squared       =    0.8509
Total |  823.716333       568  1.45020481   Root MSE        =    .46629

------------------------------------------------------------------------------
lnlabor |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lnwage |  -.8555786   .0718764   -11.90   0.000    -.9967562   -.7144009
lnoutput |   1.034611   .0273057    37.89   0.000     .9809776    1.088244
lncapital |  -.0568635   .0215757    -2.64   0.009     -.099242   -.0144851
_cons |   5.895357   .2476376    23.81   0.000     5.408954     6.38176
------------------------------------------------------------------------------

. * Figure 4.2 Actual and fitted consumption of ice cream

. use "Data/icecream.dta", clear
. reg cons income price

Source |       SS           df       MS      Number of obs   =        30
-------------+----------------------------------   F(2, 27)        =      0.98
Model |  .008509865         2  .004254932   Prob > F        =    0.3876
Residual |  .117013493        27  .004333833   R-squared       =    0.0678
Total |  .125523358        29  .004328392   Root MSE        =    .06583

------------------------------------------------------------------------------
cons |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
income |   .0002135   .0019687     0.11   0.914     -.003826     .004253
price |  -2.030037   1.473893    -1.38   0.180    -5.054216     .994143
_cons |   .9002396   .4550343     1.98   0.058    -.0334136    1.833893
------------------------------------------------------------------------------

. predict xb, xb
. twoway (scatter cons time) (line xb time), title("Figure 4.2 Actual and fitted consumption of ice
cream, March 1951-July 1953", size(*.65)) ytitle(Consumption) xtitle(Time) legend(off)
. graph export figure4_2.png, replace
(file figure4_2.png written in JPEG format)

. * Figure 4.3 Ice cream consumption, price and temperature/100
. g temp100 = temp/100

. twoway  (line temp100 time) (line cons time, lpattern(dash_3dot)) (line price time, lpattern(dash)
), title("Figure  4.3 Ice cream consumption, price and temperature/100", size(*.65)) ytitle() xtit
le(Time) legend(ring(0) position(6) cols(3) size(vsmall))

. graph export figure4_3.png, replace
(file figure4_3.png written in JPEG format)

. * Table 4.9 OLS results
. tsset time
time variable:  time, 1 to 30
delta:  1 unit

. reg cons income price temp

Source |       SS           df       MS      Number of obs   =        30
-------------+----------------------------------   F(3, 26)        =     22.17
Model |  .090250523         3  .030083508   Prob > F        =    0.0000
Residual |  .035272835        26  .001356647   R-squared       =    0.7190
Total |  .125523358        29  .004328392   Root MSE        =    .03683

------------------------------------------------------------------------------
cons |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
income |   .0033078   .0011714     2.82   0.009     .0008999    .0057156
price |  -1.044413    .834357    -1.25   0.222    -2.759458    .6706322
temp |   .0034584   .0004455     7.76   0.000     .0025426    .0043743
_cons |   .1973149   .2702161     0.73   0.472    -.3581223     .752752
------------------------------------------------------------------------------

. estat dwatson

Durbin-Watson d-statistic(  4,    30) =  1.021169

. * Figure 4.4 Actual and fitted values (connected) of ice cream consumption

. predict xb2, xb
. twoway (scatter cons time) (line xb2 time), title("Figure 4.2 Figure 4.4 Actual and fitted values
of ice cream consumption", size(*.65)) ytitle(Consumption) xtitle(Time) legend(off)
. graph export figure4_4.png, replace
(file figure4_4.png written in PNG format)

. * Table 4.10 EGLS (iterative Cochrane-Orcutt) results

. prais cons income price temp, corc

Iteration 0:  rho = 0.0000
Iteration 1:  rho = 0.4006
Iteration 2:  rho = 0.4008
Iteration 3:  rho = 0.4009
Iteration 4:  rho = 0.4009
Iteration 5:  rho = 0.4009
Iteration 6:  rho = 0.4009
Iteration 7:  rho = 0.4009

Cochrane-Orcutt AR(1) regression -- iterated estimates

Source |       SS           df       MS      Number of obs   =        29
-------------+----------------------------------   F(3, 25)        =     15.40
Model |  .047040596         3  .015680199   Prob > F        =    0.0000
Residual |  .025451894        25  .001018076   R-squared       =    0.6489
Total |  .072492491        28  .002589018   Root MSE        =    .03191

------------------------------------------------------------------------------
cons |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
income |   .0032027   .0015461     2.07   0.049     .0000186    .0063869
price |  -.8923963   .8108501    -1.10   0.282    -2.562373    .7775807
temp |   .0035584   .0005547     6.42   0.000      .002416    .0047008
_cons |   .1571479   .2896292     0.54   0.592    -.4393546    .7536504
-------------+----------------------------------------------------------------
rho |   .4009256
------------------------------------------------------------------------------
Durbin-Watson statistic (original)    1.021169
Durbin-Watson statistic (transformed) 1.548837

. * Table 4.11 OLS results extended specification
. reg cons income price temp l.temp

Source |       SS           df       MS      Number of obs   =        29
-------------+----------------------------------   F(4, 24)        =     28.98
Model |  .103387183         4  .025846796   Prob > F        =    0.0000
Residual |  .021406049        24  .000891919   R-squared       =    0.8285
Total |  .124793232        28  .004456901   Root MSE        =    .02987

------------------------------------------------------------------------------
cons |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
income |   .0028673   .0010533     2.72   0.012     .0006934    .0050413
price |  -.8383021   .6880205    -1.22   0.235    -2.258307    .5817025
|
temp |
--. |   .0053321   .0006704     7.95   0.000     .0039484    .0067158
L1. |  -.0022039   .0007307    -3.02   0.006    -.0037119   -.0006959
|
_cons |   .1894822   .2323169     0.82   0.423    -.2899963    .6689607
------------------------------------------------------------------------------

. * Figure 4.6 US\$/EUR and US\$/GBP exchange rates, January 1979-December 2001

.  u "Data/Forward5.dta", clear
.  tsset dateid01
time variable:  dateid01, 01jan1979 to 01dec2001, but with gaps
delta:  1 day
.  twoway (line exusbp dateid01) (line exuseur dateid01), ytitle() xtitle(Date) tlabel(#15, angle(fo
rty_five)) title("Figure 4.6 US\$/EUR and US\$/GBP exchange rates, January 1979 - December 2001", si
ze(*.65)) legend(off)
. graph export figure4_6.png, replace
(file figure4_6.png written in JPEG format)

. * Figure 4.7 Forward discount, US\$/EUR and US\$/GBP, January 1979-December 2001

. g diff1 = exusbp - f1usbp
. g diff2 = exuseur - f1useur
.  twoway (line diff1 dateid01) (line diff2 dateid01), ytitle() xtitle(Date) tlabel(#15, angle(forty
_five)) title("Figure 4.7 Forward discount, US\$/EUR and US\$/GBP, January 1979-December 2001", size
(*.65)) legend(off)
. graph export figure4_7.png, replace
(file figure4_7.png written in JPEG format)

. log close
name:  SN
log:  \5iexample4_s.smcl
log type:  smcl
closed on:   5 Jun 2020, 20:25:56
----------------------------------------------------------------------------------------------------

Previous | Home | Wooldridge I | Wooldridge II | Greene 8ed | Verbeek 5ed |  Report Error | Next

```