## Chapter 10 Time Series - Examples

```------------------------------------------------------------------------------------------
name:  SN
log:  ~Wooldridge\intro-econx\iexample10.smcl
log type:  smcl
opened on:  14 Jan 2019, 15:34:49

. **********************************************
. * Solomon Negash - Replicating Examples
. * Wooldridge (2016). Introductory Econometrics: A Modern Approach. 6th ed.
. * STATA Program, version 15.1.

. * Chapter 10 Basic Regression Analysis with Time Series Data
. * Computer Exercises (Examples)
. ******************** SETUP *********************

. *Example 10.1. Static Phillips Curve
. u phillips, clear
. reg inf unem

Source |       SS           df       MS      Number of obs   =        49
-------------+----------------------------------   F(1, 47)        =      2.62
Model |  25.6369575         1  25.6369575   Prob > F        =    0.1125
Residual |   460.61979        47  9.80042107   R-squared       =    0.0527
Total |  486.256748        48  10.1303489   Root MSE        =    3.1306

------------------------------------------------------------------------------
inf |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
unem |   .4676257   .2891262     1.62   0.112    -.1140213    1.049273
_cons |    1.42361   1.719015     0.83   0.412    -2.034602    4.881822
------------------------------------------------------------------------------

. *Example 10.2.  Effects of Inflation and Deficits on Interest Rates
. 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
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
------------------------------------------------------------------------------
. display _b[inf]
.60586586

. *Example 10.3. Puerto Rican Employment and the Minimum Wage
. u prminwge, clear
. reg lprepop lmincov lusgnp

Source |       SS           df       MS      Number of obs   =        38
-------------+----------------------------------   F(2, 35)        =     34.04
Model |  .211258366         2  .105629183   Prob > F        =    0.0000
Residual |  .108600151        35  .003102861   R-squared       =    0.6605
Total |  .319858518        37  .008644825   Root MSE        =     .0557

------------------------------------------------------------------------------
lprepop |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lmincov |  -.1544442   .0649015    -2.38   0.023    -.2862011   -.0226872
lusgnp |  -.0121888   .0885134    -0.14   0.891    -.1918806     .167503
_cons |  -1.054423   .7654065    -1.38   0.177     -2.60828    .4994351
------------------------------------------------------------------------------

. *Example 10.4. Effects of Personal Exemption on Fertility Rates
. u fertil3, clear
. reg gfr pe ww2 pill

Source |       SS           df       MS      Number of obs   =        72
-------------+----------------------------------   F(3, 68)        =     20.38
Model |  13183.6215         3  4394.54049   Prob > F        =    0.0000
Residual |  14664.2739        68  215.651087   R-squared       =    0.4734
Total |  27847.8954        71  392.223879   Root MSE        =    14.685

------------------------------------------------------------------------------
gfr |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
pe |     .08254   .0296462     2.78   0.007     .0233819    .1416981
ww2 |   -24.2384   7.458253    -3.25   0.002    -39.12111   -9.355684
pill |  -31.59403   4.081068    -7.74   0.000    -39.73768   -23.45039
_cons |   98.68176   3.208129    30.76   0.000     92.28003    105.0835
------------------------------------------------------------------------------

. reg gfr pe pe_1 pe_2 ww2 pill

Source |       SS           df       MS      Number of obs   =        70
-------------+----------------------------------   F(5, 64)        =     12.73
Model |  12959.7886         5  2591.95772   Prob > F        =    0.0000
Residual |  13032.6443        64  203.635067   R-squared       =    0.4986
Total |  25992.4329        69  376.701926   Root MSE        =     14.27

------------------------------------------------------------------------------
gfr |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
pe |   .0726718   .1255331     0.58   0.565    -.1781094     .323453
pe_1 |  -.0057796   .1556629    -0.04   0.970     -.316752    .3051929
pe_2 |   .0338268   .1262574     0.27   0.790    -.2184013     .286055
ww2 |   -22.1265   10.73197    -2.06   0.043    -43.56608   -.6869196
pill |  -31.30499   3.981559    -7.86   0.000    -39.25907   -23.35091
_cons |    95.8705   3.281957    29.21   0.000     89.31403     102.427
------------------------------------------------------------------------------
. display _b[pe] + _b[pe_1] + _b[pe_2]
.10071909

. *Example 10.5. Antidumping Filings and Chemical Imports
. u barium, clear
. reg lchnimp lchempi lgas lrtwex befile6 affile6 afdec6

Source |       SS           df       MS      Number of obs   =       131
-------------+----------------------------------   F(6, 124)       =      9.06
Model |  19.4051607         6  3.23419346   Prob > F        =    0.0000
Residual |  44.2470875       124  .356831351   R-squared       =    0.3049
Total |  63.6522483       130  .489632679   Root MSE        =    .59735

------------------------------------------------------------------------------
lchnimp |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lchempi |   3.117193   .4792021     6.50   0.000     2.168718    4.065668
lgas |   .1963504   .9066172     0.22   0.829    -1.598099      1.9908
lrtwex |   .9830183   .4001537     2.46   0.015     .1910022    1.775034
befile6 |   .0595739   .2609699     0.23   0.820    -.4569585    .5761064
affile6 |  -.0324064   .2642973    -0.12   0.903    -.5555249     .490712
afdec6 |   -.565245   .2858352    -1.98   0.050    -1.130993    .0005028
_cons |    -17.803   21.04537    -0.85   0.399    -59.45769    23.85169
------------------------------------------------------------------------------
. display 100*(exp(_b[afdec6]) -1)
-43.177908

. *Example 10.6. Election Outcomes and Economic Performance
. u fair, clear

. reg demvote partyWH incum c.partyWH#c.gnew c.partyWH#c.inf if year<1996

Source |       SS           df       MS      Number of obs   =        20
-------------+----------------------------------   F(4, 15)        =      7.37
Model |  .072465402         4  .018116351   Prob > F        =    0.0017
Residual |  .036853881        15  .002456925   R-squared       =    0.6629
Total |  .109319283        19  .005753646   Root MSE        =    .04957

-----------------------------------------------------------------------------------
demvote |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
partyWH |  -.0434752    .040459    -1.07   0.300    -.1297114    .0427611
incum |   .0543902   .0234166     2.32   0.035      .004479    .1043015
c.partyWH#c.gnews |   .0108466   .0041267     2.63   0.019     .0020508    .0196424
c.partyWH#c.inf |  -.0077017   .0032567    -2.36   0.032    -.0146432   -.0007602
_cons |    .481062   .0122631    39.23   0.000     .4549238    .5072002
-----------------------------------------------------------------------------------
. display _b[_cons] + _b[partyWH] + _b[incum] + _b[c.partyWH#c.gnew]*3 + _b[c.partyWH#c.inf]*3.019
.5012655

. *Example 10.7. Housing Investment and Prices
. u hseinv, clear
. reg linvpc lprice

Source |       SS           df       MS      Number of obs   =        42
-------------+----------------------------------   F(1, 40)        =     10.53
Model |  .254364468         1  .254364468   Prob > F        =    0.0024
Residual |  .966255566        40  .024156389   R-squared       =    0.2084
Total |  1.22062003        41   .02977122   Root MSE        =    .15542

------------------------------------------------------------------------------
linvpc |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lprice |   1.240943   .3824192     3.24   0.002     .4680452    2.013841
_cons |  -.5502345   .0430266   -12.79   0.000    -.6371945   -.4632746
------------------------------------------------------------------------------

. reg linvpc lprice t

Source |       SS           df       MS      Number of obs   =        42
-------------+----------------------------------   F(2, 39)        =     10.08
Model |  .415945108         2  .207972554   Prob > F        =    0.0003
Residual |  .804674927        39   .02063269   R-squared       =    0.3408
Total |  1.22062003        41   .02977122   Root MSE        =    .14364

------------------------------------------------------------------------------
linvpc |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lprice |  -.3809612   .6788352    -0.56   0.578    -1.754035    .9921125
t |   .0098287   .0035122     2.80   0.008     .0027246    .0169328
_cons |  -.9130595   .1356133    -6.73   0.000    -1.187363   -.6387557
------------------------------------------------------------------------------

. *Example 10.8. Fertility Equation
. u fertil3, clear
. reg gfr pe ww2 pill t

Source |       SS           df       MS      Number of obs   =        72
-------------+----------------------------------   F(4, 67)        =     32.84
Model |  18441.2357         4  4610.30894   Prob > F        =    0.0000
Residual |  9406.65967        67  140.397905   R-squared       =    0.6622
Total |  27847.8954        71  392.223879   Root MSE        =    11.849

------------------------------------------------------------------------------
gfr |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
pe |   .2788778   .0400199     6.97   0.000     .1989978    .3587578
ww2 |  -35.59228   6.297377    -5.65   0.000     -48.1619   -23.02266
pill |   .9974479    6.26163     0.16   0.874    -11.50082    13.49571
t |  -1.149872   .1879038    -6.12   0.000    -1.524929   -.7748145
_cons |   111.7694   3.357765    33.29   0.000     105.0673    118.4716
------------------------------------------------------------------------------

. reg gfr pe ww2 pill t tsq

Source |       SS           df       MS      Number of obs   =        72
-------------+----------------------------------   F(5, 66)        =     35.09
Model |  20236.3981         5  4047.27961   Prob > F        =    0.0000
Residual |  7611.49734        66  115.325717   R-squared       =    0.7267
Total |  27847.8954        71  392.223879   Root MSE        =    10.739

------------------------------------------------------------------------------
gfr |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
pe |   .3478126   .0402599     8.64   0.000     .2674311     .428194
ww2 |  -35.88028   5.707921    -6.29   0.000    -47.27651   -24.48404
pill |  -10.11972   6.336094    -1.60   0.115    -22.77014    2.530696
t |  -2.531426   .3893863    -6.50   0.000    -3.308861   -1.753991
tsq |   .0196126    .004971     3.95   0.000     .0096876    .0295377
_cons |   124.0919   4.360738    28.46   0.000     115.3854    132.7984
------------------------------------------------------------------------------

. *Example 10.9. Puerto Rican Employment
. u prminwge, clear
. reg lprepop lmincov lusgnp t

Source |       SS           df       MS      Number of obs   =        38
-------------+----------------------------------   F(3, 34)        =     62.78
Model |  .270948453         3  .090316151   Prob > F        =    0.0000
Residual |  .048910064        34  .001438531   R-squared       =    0.8471
Total |  .319858518        37  .008644825   Root MSE        =    .03793

------------------------------------------------------------------------------
lprepop |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lmincov |  -.1686949   .0442463    -3.81   0.001    -.2586142   -.0787757
lusgnp |   1.057351   .1766369     5.99   0.000     .6983813     1.41632
t |  -.0323542   .0050227    -6.44   0.000    -.0425616   -.0221468
_cons |  -8.696298   1.295764    -6.71   0.000    -11.32961   -6.062988
------------------------------------------------------------------------------

. *Example 10.10. Housing Investment
. u hseinv, clear
. reg linvpc lprice t

Source |       SS           df       MS      Number of obs   =        42
-------------+----------------------------------   F(2, 39)        =     10.08
Model |  .415945108         2  .207972554   Prob > F        =    0.0003
Residual |  .804674927        39   .02063269   R-squared       =    0.3408
Total |  1.22062003        41   .02977122   Root MSE        =    .14364

------------------------------------------------------------------------------
linvpc |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lprice |  -.3809612   .6788352    -0.56   0.578    -1.754035    .9921125
t |   .0098287   .0035122     2.80   0.008     .0027246    .0169328
_cons |  -.9130595   .1356133    -6.73   0.000    -1.187363   -.6387557
------------------------------------------------------------------------------
. qui reg linvpc t
. predict uh, res
. eststo Detrended: qui reg uh lprice t
. eststo Trended: qui reg linvpc lprice 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(invpc))

Dependent Variables: log(invpc)
----------------------------------------------
Detrended      Trended
b/se         b/se
----------------------------------------------
lprice                    -0.3810      -0.3810
(0.6788)     (0.6788)
t                          0.0017       0.0098
(0.0035)     (0.0035)
intercept                 -0.0718      -0.9131
(0.1356)     (0.1356)
----------------------------------------------
R-squared                   0.008        0.341
N                              42           42
---------------------------------------------
. est clear

. *Example 10.11. Effects of Antidumping Filings
. u barium, clear
. reg lchnimp lchempi lgas lrtwex befile6 affile6 afdec6 feb-dec

Source |       SS           df       MS      Number of obs   =       131
-------------+----------------------------------   F(17, 113)      =      3.71
Model |  22.8083523        17  1.34166778   Prob > F        =    0.0000
Residual |   40.843896       113  .361450407   R-squared       =    0.3583
Total |  63.6522483       130  .489632679   Root MSE        =    .60121

------------------------------------------------------------------------------
lchnimp |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lchempi |    3.26506   .4929302     6.62   0.000     2.288476    4.241644
lgas |  -1.278121   1.389008    -0.92   0.359    -4.029997    1.473755
lrtwex |   .6630496   .4713038     1.41   0.162    -.2706882    1.596787
befile6 |   .1397024   .2668075     0.52   0.602    -.3888914    .6682962
affile6 |   .0126317   .2786866     0.05   0.964    -.5394967    .5647601
afdec6 |  -.5213006     .30195    -1.73   0.087    -1.119518    .0769168
feb |  -.4177089   .3044445    -1.37   0.173    -1.020868    .1854505
mar |   .0590528   .2647308     0.22   0.824    -.4654266    .5835322
apr |  -.4514825   .2683865    -1.68   0.095    -.9832046    .0802396
may |   .0333085   .2692425     0.12   0.902    -.5001093    .5667264
jun |  -.2063321   .2692515    -0.77   0.445    -.7397679    .3271038
jul |   .0038354   .2787665     0.01   0.989    -.5484513    .5561222
aug |  -.1570652   .2779928    -0.56   0.573    -.7078191    .3936887
sep |  -.1341606   .2676556    -0.50   0.617    -.6644348    .3961135
oct |   .0516921   .2668512     0.19   0.847    -.4769883    .5803725
nov |    -.24626   .2628272    -0.94   0.351     -.766968     .274448
dec |   .1328368   .2714234     0.49   0.626    -.4049019    .6705755
_cons |   16.77877   32.42865     0.52   0.606    -47.46824    81.02577
------------------------------------------------------------------------------
. test feb mar apr may jun jul aug sep oct nov dec

( 1)  feb = 0
( 2)  mar = 0
( 3)  apr = 0
( 4)  may = 0
( 5)  jun = 0
( 6)  jul = 0
( 7)  aug = 0
( 8)  sep = 0
( 9)  oct = 0
(10)  nov = 0
(11)  dec = 0

F( 11,   113) =    0.86
Prob > F =    0.5852

. reg lchnimp lchempi lgas lrtwex befile6 affile6 afdec6 spr sum fall

Source |       SS           df       MS      Number of obs   =       131
-------------+----------------------------------   F(9, 121)       =      6.03
Model |  19.7126415         9  2.19029349   Prob > F        =    0.0000
Residual |  43.9396068       121  .363137247   R-squared       =    0.3097
Total |  63.6522483       130  .489632679   Root MSE        =    .60261

------------------------------------------------------------------------------
lchnimp |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lchempi |   3.077933   .4861354     6.33   0.000       2.1155    4.040367
lgas |   .5650851   1.000208     0.56   0.573     -1.41509     2.54526
lrtwex |   1.101474   .4246085     2.59   0.011     .2608498    1.942099
befile6 |   .0766913   .2650022     0.29   0.773    -.4479504    .6013329
affile6 |  -.0832898   .2728272    -0.31   0.761    -.6234233    .4568437
afdec6 |  -.6211993   .2954242    -2.10   0.038    -1.206069   -.0363292
spr |  -.0412246   .1511745    -0.27   0.786    -.3405145    .2580652
sum |  -.1519034    .169261    -0.90   0.371    -.4870002    .1831935
fall |  -.0672783   .1544774    -0.44   0.664     -.373107    .2385504
_cons |  -26.52188   23.29748    -1.14   0.257    -72.64538    19.60162
------------------------------------------------------------------------------
. test spr sum fall

( 1)  spr = 0
( 2)  sum = 0
( 3)  fall = 0

F(  3,   121) =    0.28
Prob > F =    0.8381

. log close
name:  SN
log:  ~Wooldridge\intro-econx\iexample10.smcl
log type:  smcl
closed on:  14 Jan 2019, 15:34:50
------------------------------------------------------------------------------------------
```