INTRODUCTORY ECONOMETRICS – REPLICATING EXAMPLES

Chapter 12 – Serial correlation

------------------------------------------------------------------------------------------
      name:  SN
       log:  ~Wooldridge\intro-econx\iexample12.smcl
  log type:  smcl
 opened on:  15 Jan 2019, 17:38:45
. **********************************************
. * Solomon Negash - Replicating Examples
. * Wooldridge (2016). Introductory Econometrics: A Modern Approach. 6th ed.  
. * STATA Program, version 15.1. 

. * Chapter 12 Serial Correlation and Heteroskedasticity in Time Series Regressions
. * Computer Exercises (Examples)
. ******************** SETUP *********************

. *Example 12.1. Testing for AR(1) Serial Correlation in the Phillips Curve
. u phillips, clear
. qui reg inf unem
. predict us, res
. g us_1 = us[_n-1]
(1 missing value generated)
. reg us us_1
      Source |       SS           df       MS      Number of obs   =        48
-------------+----------------------------------   F(1, 46)        =     24.34
       Model |   150.91704         1   150.91704   Prob > F        =    0.0000
    Residual |  285.198412        46  6.19996547   R-squared       =    0.3460
-------------+----------------------------------   Adj R-squared   =    0.3318
       Total |  436.115452        47  9.27905217   Root MSE        =      2.49
------------------------------------------------------------------------------
          us |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        us_1 |   .5729695   .1161334     4.93   0.000     .3392052    .8067338
       _cons |  -.1133967    .359404    -0.32   0.754    -.8368393     .610046
------------------------------------------------------------------------------
. qui reg cinf unem
. predict ua, res
(1 missing value generated)
. g ua_1 = ua[_n-1]
(2 missing values generated)
. reg ua ua_1
      Source |       SS           df       MS      Number of obs   =        47
-------------+----------------------------------   F(1, 45)        =      0.08
       Model |  .350024192         1  .350024192   Prob > F        =    0.7752
    Residual |  190.837382        45  4.24083071   R-squared       =    0.0018
-------------+----------------------------------   Adj R-squared   =   -0.0204
       Total |  191.187406        46  4.15624796   Root MSE        =       2.0593
------------------------------------------------------------------------------
          ua |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        ua_1 |  -.0355928   .1238908    -0.29   0.775    -.2851216     .213936
       _cons |   .1941655   .3003839     0.65   0.521    -.4108388    .7991698
------------------------------------------------------------------------------

. *Example 12.2. Testing for AR(1) Serial Correlation in the Minimum Wage Equation
. u prminwge, clear
. qui reg lprepop lmincov lprgnp lusgnp t
. predict u, res
. g u_1 = u[_n-1]
(1 missing value generated)
. reg u  lmincov lprgnp lusgnp t u_1

      Source |       SS           df       MS      Number of obs   =        37
-------------+----------------------------------   F(5, 31)        =      1.98
       Model |  .007527192         5  .001505438   Prob > F        =   0.1089
    Residual |  .023530328        31  .000759043   R-squared       =   0.2424
-------------+----------------------------------   Adj R-squared   =    0.1202
       Total |   .03105752        36  .000862709   Root MSE        =      .02755
------------------------------------------------------------------------------
           u |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
     lmincov |   .0375001   .0352123     1.06   0.295    -.0343159     .109316
      lprgnp |  -.0784656    .070524    -1.11   0.274    -.2223003     .065369
      lusgnp |   .2039325   .1951588     1.04   0.304    -.1940965    .6019614
           t |  -.0034662   .0040736    -0.85   0.401    -.0117743    .0048419
         u_1 |   .4805093   .1664442     2.89   0.007     .1410441    .8199745
       _cons |  -.8507721   1.092691    -0.78   0.442    -3.079329    1.377785
------------------------------------------------------------------------------
. reg u u_1
      Source |       SS           df       MS      Number of obs   =        37
-------------+----------------------------------   F(1, 35)        =      6.89
       Model |   .00511108         1   .00511108   Prob > F        =    0.0127
    Residual |   .02594644        35  .000741327   R-squared       =    0.1646
-------------+----------------------------------   Adj R-squared   =    0.1407
       Total |   .03105752        36  .000862709   Root MSE        =      .02723
------------------------------------------------------------------------------
           u |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         u_1 |   .4173219   .1589351     2.63   0.013     .0946666    .7399772
       _cons |  -.0008953   .0044883    -0.20   0.843    -.0100071    .0082165
------------------------------------------------------------------------------

. *Example 12.3. Testing for AR(3) Serial Correlation
. u barium, clear
. qui reg lchnimp lchempi lgas lrtwex befile6 affile6 afdec6
. predict u, res
. g u_1 = u[_n-1]
(1 missing value generated)
. g u_2 = u[_n-2]
(2 missing values generated)
. g u_3 = u[_n-3]
(3 missing values generated)
. reg u lchempi lgas lrtwex befile6 affile6 afdec6 u_1 u_2 u_3
      Source |       SS           df       MS      Number of obs   =       128
-------------+----------------------------------   F(9, 118)       =      1.72
       Model |  5.03370599         9  .559300665   Prob > F        =    0.0920
    Residual |  38.3936622       118  .325370019   R-squared       =    0.1159
-------------+----------------------------------   Adj R-squared   =    0.0485
       Total |  43.4273682       127  .341947781   Root MSE        =      .57041
------------------------------------------------------------------------------
           u |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
     lchempi |  -.1431582   .4720253    -0.30   0.762    -1.077897    .7915804
        lgas |    .623307   .8859741     0.70   0.483    -1.131163    2.377777
      lrtwex |   .1786676   .3910343     0.46   0.649    -.5956868    .9530219
     befile6 |  -.0859236   .2510066    -0.34   0.733    -.5829851    .4111379
     affile6 |  -.1221207   .2546984    -0.48   0.632    -.6264928    .3822514
      afdec6 |   -.066829   .2743668    -0.24   0.808    -.6101499    .4764919
         u_1 |   .2214913   .0916573     2.42   0.017     .0399849    .4029977
         u_2 |   .1340412   .0921595     1.45   0.148    -.0484597    .3165421
         u_3 |   .1255427   .0911194     1.38   0.171    -.0548985    .3059838
       _cons |  -14.36915   20.65567    -0.70   0.488    -55.27299    26.53469
------------------------------------------------------------------------------
. test u_1 u_2 u_3
 ( 1)  u_1 = 0
 ( 2)  u_2 = 0
 ( 3)  u_3 = 0
       F(  3,   118) =    5.12
            Prob > F =    0.0023

. *Example 12.4. Prais-Winsten Estimation in the Event Study
. u barium, clear
. tsset t
        time variable:  t, 1 to 131
                delta:  1 unit
. local x "lchempi lgas lrtwex befile6 affile6 afdec6"
. eststo OLS: qui reg lchnimp `x'
. eststo PW: qui prais lchnimp `x'
. estout , cells(b(nostar fmt(2)) se(par fmt(3))) stats(rho N r2, fmt(%9.3f %9.0g %9.3f ) ///
labels(rho Observations R-squared )) varlabels(_cons intercept) varwidth(20) ti(Table 12.1 ///
Dependent Variable: log(chnimp))

Table 12.1 Dependent Variable: log(chnimp)
----------------------------------------------
                              OLS           PW
                             b/se         b/se
----------------------------------------------
lchempi                      3.12         2.94
                          (0.479)      (0.633)
lgas                         0.20         1.05
                          (0.907)      (0.977)
lrtwex                       0.98         1.13
                          (0.400)      (0.507)
befile6                      0.06        -0.02
                          (0.261)      (0.319)
affile6                     -0.03        -0.03
                          (0.264)      (0.322)
afdec6                      -0.57        -0.58
                          (0.286)      (0.342)
intercept                  -17.80       -37.08
                         (21.045)     (22.778)
----------------------------------------------
rho                                      0.293
Observations                  131          131
R-squared                   0.305        0.202
----------------------------------------------
. est clear

. *Example 12.5. Static Phillips Curve
. u phillips, clear
. tsset year
        time variable:  year, 1948 to 1996
                delta:  1 unit
. eststo OLS: qui reg inf unem
. eststo PW: qui prais inf unem
. estout , cells(b(nostar fmt(3)) se(par fmt(3))) stats(rho N r2, fmt(%9.3f %9.0g %9.3f ) ///
labels(rho Observations R-squared )) varlabels(_cons intercept) varwidth(20) ti(Table 12.2 ///
Dependent Variable: inf)

Table 12.2 Dependent Variable: inf
----------------------------------------------
                              OLS           PW
                             b/se         b/se
----------------------------------------------
unem                        0.468       -0.716
                          (0.289)      (0.313)
intercept                   1.424        8.296
                          (1.719)      (2.231)
----------------------------------------------
rho                                      0.781
Observations                   49           49
R-squared                   0.053        0.136
----------------------------------------------
. est clear

. *Example 12.6. Differencing the Interest Rate Equation
. bcuse intdef, clear
Contains data from http://fmwww.bc.edu/ec-p/data/wooldridge/intdef.dta
  obs:            56                          
 vars:            13                          25 Jul 2005 15:25
 size:         2,632                          
------------------------------------------------------------------------------------------
              storage   display    value
variable name   type    format     label      variable label
------------------------------------------------------------------------------------------
year            int     %9.0g                 1948 to 2003
i3              float   %9.0g                 3 month T-bill rate
inf             float   %9.0g                 CPI inflation rate
rec             float   %9.0g                 federal receipts, % GDP
out             float   %9.0g                 federal outlays, % GDP
def             float   %9.0g                 out - rec
i3_1            float   %9.0g                 i3[_n-1]
inf_1           float   %9.0g                 inf[_n-1]
def_1           float   %9.0g                 def[_n-1]
ci3             float   %9.0g                 i3 - i3_1
cinf            float   %9.0g                 inf - inf_1
cdef            float   %9.0g                 def - def_1
y77             byte    %9.0g                 =1 if year >= 1977;
change in FY
------------------------------------------------------------------------------------------
Sorted by:
. reg i3 inf def

      Source |       SS           df       MS      Number of obs   =        56
-------------+----------------------------------   F(2, 53)        =     40.09
       Model |  272.420338         2  136.210169   Prob > F        =    0.0000
    Residual |  180.054275        53  3.39725047   R-squared       =    0.6021
-------------+----------------------------------   Adj R-squared   =    0.5871
       Total |  452.474612        55  8.22681113   Root MSE        =    1.8432
------------------------------------------------------------------------------
          i3 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         inf |   .6058659   .0821348     7.38   0.000     .4411243    .7706074
         def |   .5130579   .1183841     4.33   0.000     .2756095    .7505062
       _cons |   1.733266    .431967     4.01   0.000     .8668497    2.599682
------------------------------------------------------------------------------
. predict u, res
. g u_1 = u[_n-1]
(1 missing value generated)
. reg u u_1
      Source |       SS           df       MS      Number of obs   =        55
-------------+----------------------------------   F(1, 53)        =     32.13
       Model |  63.9253768         1  63.9253768   Prob > F        =    0.0000
    Residual |  105.435729        53  1.98935339   R-squared       =    0.3775
-------------+----------------------------------   Adj R-squared   =    0.3657
       Total |  169.361106        54  3.13631678   Root MSE        =    1.4104
------------------------------------------------------------------------------
           u |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         u_1 |   .6225242   .1098185     5.67   0.000     .4022562    .8427922
       _cons |   .0153323   .1903397     0.08   0.936    -.3664407    .3971053
------------------------------------------------------------------------------

. reg ci3 cinf cdef
      Source |       SS           df       MS      Number of obs   =        55
-------------+----------------------------------   F(2, 52)        =      5.57
       Model |  17.8058166         2  8.90290831   Prob > F        =    0.0065
    Residual |  83.1753705        52  1.59952636   R-squared       =    0.1763
-------------+----------------------------------   Adj R-squared   =    0.1446
       Total |  100.981187        54  1.87002198   Root MSE        =    1.2647
------------------------------------------------------------------------------
         ci3 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        cinf |   .1494892   .0921555     1.62   0.111    -.0354343    .3344127
        cdef |  -.1813151   .1476825    -1.23   0.225    -.4776618    .1150315
       _cons |   .0417738   .1713874     0.24   0.808    -.3021401    .3856877
------------------------------------------------------------------------------
. corr i3 i3_1
(obs=55)
             |       i3     i3_1
-------------+------------------
          i3 |   1.0000
        i3_1 |   0.8845   1.0000

. predict e, res
(1 missing value generated)
. g e_1 = e[_n-1]
(2 missing values generated)
. reg e e_1
      Source |       SS           df       MS      Number of obs   =        54
-------------+----------------------------------   F(1, 52)        =      0.29
       Model |  .429432502         1  .429432502   Prob > F        =    0.5944
    Residual |  77.7882033        52  1.49592699   R-squared       =    0.0055
-------------+----------------------------------   Adj R-squared   =   -0.0136
       Total |  78.2176358        53  1.47580445   Root MSE        =    1.2231
------------------------------------------------------------------------------
           e |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         e_1 |    .071925   .1342418     0.54   0.594    -.1974509    .3413009
       _cons |   -.041392   .1664432    -0.25   0.805    -.3753848    .2926007
------------------------------------------------------------------------------

. *Example 12.7. The Puerto Rican Minimum Wage
. u prminwge, clear
. tsset year
        time variable:  year, 1950 to 1987
                delta:  1 unit
. eststo OLS: qui reg lprepop lmincov lprgnp lusgnp t
. eststo Newey: qui newey lprepop lmincov lprgnp lusgnp t, lag(2)
. eststo Pw: qui prais lprepop lmincov lprgnp lusgnp t
. estout , cells(b(nostar fmt(4)) se(par fmt(4))) stats(r2 r2_a N, fmt(%9.3f %9.3f %9.0g) ///
labels(R-squared Adj-R-squared N)) varlabels(_cons intercept) varwidth(20) ti(Dependent ///
Variables: log(prepop))

Dependent Variables: log(prepop)
-----------------------------------------------------------
                              OLS        Newey           Pw
                             b/se         b/se         b/se
-----------------------------------------------------------
lmincov                   -0.2123      -0.2123      -0.1477
                         (0.0402)     (0.0457)     (0.0458)
lprgnp                     0.2852       0.2852       0.2514
                         (0.0805)     (0.0996)     (0.1165)
lusgnp                     0.4860       0.4860       0.2557
                         (0.2220)     (0.2791)     (0.2317)
t                         -0.0267      -0.0267      -0.0205
                         (0.0046)     (0.0058)     (0.0059)
intercept                 -6.6634      -6.6634      -4.6529
                         (1.2578)     (1.5364)     (1.3765)
-----------------------------------------------------------
R-squared                   0.889                     0.751
Adj-R-squared               0.876                     0.721
N                              38           38           38
-----------------------------------------------------------
. est clear

. *Example 12.8. Heteroskedasticity and the Efficient Markets Hypothesis
. u nyse, clear
. reg return return_1
      Source |       SS           df       MS      Number of obs   =       689
-------------+----------------------------------   F(1, 687)       =      2.40
       Model |  10.6866231         1  10.6866231   Prob > F        =    0.1218
    Residual |  3059.73817       687  4.45376735   R-squared       =    0.0035
-------------+----------------------------------   Adj R-squared   =    0.0020
       Total |  3070.42479       688  4.46282673   Root MSE        =    2.1104
------------------------------------------------------------------------------
      return |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    return_1 |   .0588984   .0380231     1.55   0.122    -.0157569    .1335538
       _cons |    .179634   .0807419     2.22   0.026     .0211034    .3381646
------------------------------------------------------------------------------
. predict u, res
(2 missing values generated)
. gen u2 = u^2
(2 missing values generated)
. reg u2 return_1
      Source |       SS           df       MS      Number of obs   =       689
-------------+----------------------------------   F(1, 687)       =     30.05
       Model |  3755.56865         1  3755.56865   Prob > F        =    0.0000
    Residual |  85846.3039       687   124.95823   R-squared       =    0.0419
-------------+----------------------------------   Adj R-squared   =    0.0405
       Total |  89601.8726       688   130.23528   Root MSE        =    11.178
------------------------------------------------------------------------------
          u2 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    return_1 |  -1.104132   .2014029    -5.48   0.000    -1.499572   -.7086933
       _cons |   4.656501   .4276789    10.89   0.000     3.816786    5.496216
------------------------------------------------------------------------------

. *Example 12.9. ARCH in Stock Returns
. u nyse, clear
. qui reg return return_1
. predict u, res
(2 missing values generated)
. gen u2 = u^2
(2 missing values generated)
. g u2_1 = u2[_n-1]
(3 missing values generated)
. reg u2  u2_1
      Source |       SS           df       MS      Number of obs   =       688
-------------+----------------------------------   F(1, 686)       =     87.92
       Model |  10177.7166         1  10177.7166   Prob > F        =    0.0000
    Residual |  79409.7636       686  115.757673   R-squared       =    0.1136
-------------+----------------------------------   Adj R-squared   =    0.1123
       Total |  89587.4802       687  130.403901   Root MSE        =    10.759

------------------------------------------------------------------------------
          u2 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        u2_1 |   .3370623   .0359468     9.38   0.000     .2664834    .4076413
       _cons |   2.947433   .4402342     6.70   0.000     2.083065    3.811801
------------------------------------------------------------------------------
. g u_1 = u[_n-1]
(3 missing values generated)
. reg u  u_1
      Source |       SS           df       MS      Number of obs   =       688
-------------+----------------------------------   F(1, 686)       =      0.00
       Model |  .006037885         1  .006037885   Prob > F        =    0.9707
    Residual |  3059.08133       686  4.45930223   R-squared       =    0.0000
-------------+----------------------------------   Adj R-squared   =   -0.0015
       Total |  3059.08737       687  4.45282004   Root MSE        =    2.1117

------------------------------------------------------------------------------
           u |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         u_1 |   .0014048   .0381773     0.04   0.971    -.0735537    .0763633
       _cons |  -.0011708    .080508    -0.01   0.988    -.1592425     .156901
------------------------------------------------------------------------------

. log close
      name:  SN
       log:  ~Wooldridge\intro-econx\iexample12.smcl
  log type:  smcl
 closed on:  15 Jan 2019, 17:38:47
------------------------------------------------------------------------------------------
0 replies

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *