Professional Documents
Culture Documents
Semester 2, 2023/24
yt = β0 + β1 xt1 + . . . + βk xtk + ut
But serially correlated errors mean that the usual OLS statistical inference is
incorrect, even in large samples.
In many cases, the inference can be very misleading.
(What is the other assumption that affects statistical inference?)
(Heteroskedasticity or HSK also invalidates the usual inference in TS
regressions.)
In some cases, we can improve over OLS by modelling the serial correlation
and using a different estimation method, but additional assumptions are
needed.
It is also possible to compute standard errors, CIs, and test statistics robust to
general forms of serial correlation – at least approximately.
These statistics are also robust to any kind of HSK.
The underlying theory is complicated, but it is easy to describe the idea.
For example, we might decide up front to allow ut to be correlated with ut−1
and ut−2 , but not the errors more than two periods apart.
The N-W standard errors are not as automated as the adjustment for HSK
because we have to choose a lag.
The choice of the lag q is debatable.
Guidelines: With annual data, the lag is usually fairly short – maybe a couple
of years, so lag = 2 – but with quarterly or monthly data we tend to try longer
lags, such as lag = 24.
Stata command
Just as with the HSK-robust inference, we can apply the HAC inference
irrespective of evidence of serial correlation.
Large differences in the HAC standard errors and the usual ones suggest
serial correlation (autocorrelation) or HSK are present.
HAC standard errors are less commonly used than HSK-robust errors for several
reasons:
HAC SEs can be poorly behaved if there is substantial serial correlation and
the sample size is small.
The lag length q must be chosen by the researcher and the standard errors
can be sensitive to the choice of lag.
That said, HAC standard errors are becoming more widespread in use.
Let’s estimate a simple reaction function for the federal funds rate (FEDFUND.DTA)
We difference ffratet , inflation, and GDP gap as they are highly persistent
(topic 4).
We obtain cffrate, cinf , and cgdpgap, where c. denotes the change in a
variable.
With quarterly data, try FDLs of order 4 in both cinf and cgdpgap.
. reg cffrate cinf cinf_1 cinf_2 cinf_3 cinf_4 cgdpgap cgdpgap_1 cgdpgap_2
cgdpgap_3 cgdpgap_4
------------------------------------------------------------------------------
cffrate | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
cinf | .1635009 .0693821 2.36 0.020 .0265158 .3004861
cinf_1 | .0892447 .0749762 1.19 0.236 -.0587852 .2372746
cinf_2 | .2397011 .0766598 3.13 0.002 .0883473 .3910549
cinf_3 | .1603425 .0742329 2.16 0.032 .0137802 .3069048
cinf_4 | .0188896 .0692756 0.27 0.785 -.1178851 .1556644
cgdpgap | .3419624 .077994 4.38 0.000 .1879743 .4959506
cgdpgap_1 | .2432981 .0796212 3.06 0.003 .0860974 .4004988
cgdpgap_2 | .1016662 .077379 1.31 0.191 -.0511077 .2544401
cgdpgap_3 | .0544501 .0335291 1.62 0.106 -.0117484 .1206486
cgdpgap_4 | -.0874404 .0774749 -1.13 0.261 -.2404035 .0655227
_cons | .0395079 .0670281 0.59 0.556 -.0928297 .1718454
------------------------------------------------------------------------------
------------------------------------------------------------------------------
| Newey-West
cffrate | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
cinf | .1635009 .0890041 1.84 0.068 -.012225 .3392269
cinf_1 | .0892447 .1168206 0.76 0.446 -.1414011 .3198905
cinf_2 | .2397011 .1328552 1.80 0.073 -.0226026 .5020048
cinf_3 | .1603425 .1170766 1.37 0.173 -.0708086 .3914936
cinf_4 | .0188896 .0738927 0.26 0.799 -.127001 .1647803
cgdpgap | .3419624 .1068802 3.20 0.002 .1309426 .5529822
cgdpgap_1 | .2432981 .0974424 2.50 0.014 .050912 .4356842
cgdpgap_2 | .1016662 .1466274 0.69 0.489 -.1878288 .3911612
cgdpgap_3 | .0544501 .0405701 1.34 0.181 -.0256499 .1345501
cgdpgap_4 | -.0874404 .07741 -1.13 0.260 -.2402755 .0653947
_cons | .0395079 .0593546 0.67 0.507 -.0776794 .1566951
------------------------------------------------------------------------------
Increasing the N-W lag to four (as would be suggested by using the integer
part of 4(n/100)2/9 )...
. newey cffrate cinf cinf_1 cinf_2 cinf_3 cinf_4 cgdpgap cgdpgap_1 cgdpgap_2
cgdpgap_3 cgdpgap_4, lag(4)
------------------------------------------------------------------------------
| Newey-West
cffrate | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
cinf | .1635009 .0913361 1.79 0.075 -.0168292 .343831
cinf_1 | .0892447 .1218877 0.73 0.465 -.1514052 .3298947
cinf_2 | .2397011 .1463759 1.64 0.103 -.0492973 .5286995
cinf_3 | .1603425 .1191334 1.35 0.180 -.0748695 .3955545
cinf_4 | .0188896 .0723094 0.26 0.794 -.1238749 .1616542
cgdpgap | .3419624 .1126093 3.04 0.003 .1196314 .5642934
cgdpgap_1 | .2432981 .0966048 2.52 0.013 .0525656 .4340306
cgdpgap_2 | .1016662 .1455609 0.70 0.486 -.1857231 .3890555
cgdpgap_3 | .0544501 .040057 1.36 0.176 -.0246368 .133537
cgdpgap_4 | -.0874404 .0724511 -1.21 0.229 -.2304848 .055604
_cons | .0395079 .0584588 0.68 0.500 -.0759106 .1549264
------------------------------------------------------------------------------
... does not change much; so standard errors are not very sensitive to the
choice of q.
Applications of Econometrics Ch. 12 Serial Correlation Semester 2, 2023/24 22 / 59
N-W/HAC Standard Errors
( 1) cinf_4 = 0
( 2) cgdpgap_4 = 0
F( 2, 166) = 0.74
Prob > F = 0.4771
------------------------------------------------------------------------------
| Newey-West
cffrate | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
cinf | .1529545 .090034 1.70 0.091 -.0247817 .3306907
cinf_1 | .0711862 .1073547 0.66 0.508 -.1407427 .2831152
cinf_2 | .2244522 .1375701 1.63 0.105 -.047125 .4960295
cinf_3 | .1428366 .0961857 1.49 0.139 -.0470436 .3327168
cgdpgap | .3387203 .1090373 3.11 0.002 .1234698 .5539708
cgdpgap_1 | .2413696 .0972818 2.48 0.014 .0493255 .4334136
cgdpgap_2 | .0886014 .1476462 0.60 0.549 -.202867 .3800698
cgdpgap_3 | .0502603 .0376323 1.34 0.183 -.0240297 .1245503
_cons | .038079 .0584926 0.65 0.516 -.0773912 .1535493
------------------------------------------------------------------------------
Overall, there seems to be evidence that the FF rate increases, phased over a
couple of quarters, when inflation increases or when the GDP gap increases
(so actual GDP is above the ideal GDP).
HSK-robust standard errors
FD lag length (3) does not match N-W lag length (4)—problematic?
No. FD lag length concerns explanatory variables, N-W lag length concerns
residuals. There is no reason for them to have the exact same length.
ut = ρut−1 + et ,
where {et } is serially uncorrelated, has a zero mean, and (usually) a constant
variance, what should we set as the null hypothesis?
H0 : ρ = 0.
Practical issues
Often ρ > 0 when there is serial correlation, but we usually use a two-sided
alternative.
If we could observe {ut }, we would just estimate a simple AR(1) model for ut
and test ρ = 0. [Because E(ut ) = 0, this is one case we would not have to
include a constant.]
But we do not observe the errors. Instead, we base a test on the OLS
residuals, ût . (Think back to the case of testing for HSK, where we used ût2 in
place of ut2 .)
Remember the difference between ût and ut : the former depends on the
estimators, β̂j .
Provided that the {xtj } are strictly exogenous (Assumption TS.3) then we can
implement the test in three steps.
1. Estimate the equation
yt = β0 + β1 xt1 + . . . + βk xtk + ut , t = 1, 2, . . . , n
ût on ût−1 ,t = 2, . . . , n
3. Compute the usual t statistic for ρ̂, and carry out the test H0 : ρ = 0 in the
usual way.
The test tends to work well in large samples.
It is often applied to static and FDL models because strict exogeneity can be
true.
and test the two lags for joint significance (using a usual F statistic).
So, for the AR(1) test, after getting the OLS residuals exactly as before, run
If we take the “∧ ” off of the residuals, we can see why we need to include the
regressors: If xtj is correlated with ut , and ut is correlated with ut−1 , then xtj
might be correlated with ut−1 .
In other words, leaving out xtj would bias the estimates.
This form of the test is more general than the previous form, even though the
previous test is somewhat more popular.
One must use the extended form if one or more of the xtj is a lag of yt , but it is
needed in other situations where strict exogeneity is violated.
------------------------------------------------------------------------------
prcfata | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
spdlaw | .0671634 .0204439 3.29 0.001 .02656 .1077668
beltlaw | -.0295827 .023093 -1.28 0.203 -.0754474 .0162819
unem | -.0154371 .0055134 -2.80 0.006 -.0263872 -.004487
feb | -.0001812 .0269749 -0.01 0.995 -.0537557 .0533933
(mar to nov omitted here)
dec | .0089053 .0275565 0.32 0.747 -.0458243 .0636349
t | -.0022355 .0004185 -5.34 0.000 -.0030668 -.0014043
_cons | 1.038472 .0571893 18.16 0.000 .924889 1.152055
------------------------------------------------------------------------------
. predict uh, resid
HAC SE Estimating ρ
. reg uh uh_1
------------------------------------------------------------------------------
uh | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
uh_1 | .2816806 .0943712 2.98 0.004 .0945599 .4688012
_cons | .0002994 .0049688 0.06 0.952 -.0095528 .0101516
------------------------------------------------------------------------------
The estimate of ρ is about .282, with tρ̂ = 2.98. What does it suggest?
There is strong evidence of serial correlation, although it is not a huge amount
of serial correlation.
The more general test (including the x ′ s) gives practically the same results:
ρ̂ = .283 and tρ̂ = 2.77.
. reg uh uh_1 spdlaw beltlaw unem feb-dec t
------------------------------------------------------------------------------
uh | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
uh_1 | .2830111 .1021103 2.77 0.007 .0801511 .4858711
spdlaw | -.0019168 .0199115 -0.10 0.924 -.0414744 .0376408
beltlaw | .0011499 .022418 0.05 0.959 -.0433874 .0456872
unem | -.000307 .0054271 -0.06 0.955 -.011089 .0104749
feb | -.0040023 .0270068 -0.15 0.883 -.057656 .0496513
(mar to nov omitted here)
dec | -.0040947 .0276155 -0.15 0.882 -.0589577 .0507684
t | -4.60e-06 .0004176 -0.01 0.991 -.0008342 .000825
_cons | .006583 .0583639 0.11 0.910 -.109367 .122533
------------------------------------------------------------------------------
Going back to the percent fatalities example, we compute the HAC standard
errors.
. newey prcfata spdlaw beltlaw unem feb-dec t, lag(4)
------------------------------------------------------------------------------
| Newey-West
prcfata | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
spdlaw | .0671634 .0264891 2.54 0.013 .0145538 .1197729
beltlaw | -.0295827 .0330354 -0.90 0.373 -.0951939 .0360284
unem | -.0154371 .0059803 -2.58 0.011 -.0273144 -.0035598
feb | -.0001812 .016465 -0.01 0.991 -.0328821 .0325197
(mar to nov omitted here)
dec | .0089053 .0283141 0.31 0.754 -.0473291 .0651396
t | -.0022355 .0005551 -4.03 0.000 -.0033381 -.001133
_cons | 1.038472 .0591372 17.56 0.000 .9210202 1.155924
------------------------------------------------------------------------------
Next, let’s test for serial correlation in the federal funds rate example.
Recall that we decided to include three lags of cinf (change in inflation) and
cgdpgap (change in GDP gap).
. reg cffrate cinf cinf_1 cinf_2 cinf_3 cgdpgap cgdpgap_1 cgdpgap_2 cgdpgap_3
------------------------------------------------------------------------------
cffrate | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
cinf | .1529545 .0680061 2.25 0.026 .0187037 .2872053
cinf_1 | .0711862 .0727929 0.98 0.330 -.0725143 .2148868
cinf_2 | .2244522 .0729376 3.08 0.002 .080466 .3684385
cinf_3 | .1428366 .0682135 2.09 0.038 .0081763 .2774969
cgdpgap | .3387203 .0769542 4.40 0.000 .186805 .4906355
cgdpgap_1 | .2413696 .0791325 3.05 0.003 .085154 .3975851
cgdpgap_2 | .0886014 .0761234 1.16 0.246 -.0616739 .2388767
cgdpgap_3 | .0502603 .0314743 1.60 0.112 -.0118731 .1123937
_cons | .038079 .0664227 0.57 0.567 -.093046 .169204
------------------------------------------------------------------------------
. reg uh uh_1
------------------------------------------------------------------------------
uh | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
uh_1 | .0192665 .0755773 0.25 0.799 -.1298939 .1684269
_cons | .000512 .0649001 0.01 0.994 -.1275757 .1285997
------------------------------------------------------------------------------
------------------------------------------------------------------------------
uh | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
uh_1 | .0243798 .0734643 0.33 0.740 -.1206218 .1693814
uh_2 | -.2571086 .0734841 -3.50 0.001 -.4021494 -.1120678
_cons | -.000234 .0632508 -0.00 0.997 -.1250766 .1246085
------------------------------------------------------------------------------
The standard errors that are robust to HSK (below) are larger than those
robust to serial correlation and HSK... meaning the robust option has failed to
account for serial correlation.
. reg cffrate cinf cinf_1 cinf_2 cinf_3 cgdpgap cgdpgap_1 cgdpgap_2 cgdpgap_3,
robust
------------------------------------------------------------------------------
| Robust
cffrate | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
cinf | .1529545 .10977 1.39 0.165 -.0637424 .3696515
cinf_1 | .0711862 .1058495 0.67 0.502 -.1377714 .2801439
cinf_2 | .2244522 .1136453 1.98 0.050 .0001049 .4487996
cinf_3 | .1428366 .094696 1.51 0.133 -.0441028 .3297761
cgdpgap | .3387203 .1162425 2.91 0.004 .1092458 .5681947
cgdpgap_1 | .2413696 .0987046 2.45 0.015 .0465168 .4362223
cgdpgap_2 | .0886014 .1482415 0.60 0.551 -.2040422 .381245
cgdpgap_3 | .0502603 .035287 1.42 0.156 -.0193998 .1199203
_cons | .038079 .0617225 0.62 0.538 -.0837674 .1599254
------------------------------------------------------------------------------
HAC standard errors
A fair question
Given the presence of HAC standard errors, why bother testing for serial
correlation in the first place?
There are several reasons why we would want to detect serial correlation
rather than just always using HAC standard errors.
1 Lag choice: HAC errors require the choice of a lag and different choices may
lead to different standard errors. If we can show that there is no serial
correlation, then we do not need to make this choice.
2 Efficiency: Without serial correlation, it is pointless to try to implement
estimation methods that improve upon OLS only in the presence of serial
correlation. In other words, OLS is efficient if there is not serial correlation.
3 Misspecification: We may have specified a model that should not have serial
correlation. For example, a model that includes a lagged dependent variable
should not have serial correlation if we have specified the error structure
correctly (e.g., an AR(1) model that includes one lag of the dependent
variable). We are testing whether the model is misspecified.
An alternative to OLS
*These procedures require that our regressors are strictly exogenous, a stronger
assumption than needed for computing HAC standard errors.
yt = β0 + β1 xt + ut (1)
where
ỹt = yt − ρyt−1 , x̃t = xt − ρxt−1 .
We call ỹt and x̃t quasi-differenced data, and they satisfy all Gauss-Markov
assumptions.
We need to add the first period of data for these GLS estimators to have the
smallest variance.
For t = 1, we have p
ỹ1 = 1 − ρ2 β0 + β1 x̃1 + ũ1 ,
where p p p
ỹ1 = 1 − ρ2 y1 , x̃1 = 1 − ρ2 x1 , and ũ1 = 1 − ρ2 u1 .
We can add more explanatory variables; we quasi-difference them using the
same formulas.
In the percent fatilities example, we first run the OLS regression here .
Next, we estimate an AR(1) model on the estimated errors.
. predict uh, resid
------------------------------------------------------------------------------
uh | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
uh_1 | .2816134 .0939201 3.00 0.003 .0954077 .467819
------------------------------------------------------------------------------
. foreach var in prcfata spdlaw beltlaw unem feb mar apr may jun jul aug sep oct nov dec t const {
2. gen ‘var’_qd = ‘var’ - rho * L.‘var’
3. replace ‘var’_qd = sqrt(1 - rho^2) * ‘var’ in 1
4. }
(1 missing value generated)
(1 real change made)
(1 missing value generated)
(1 real change made)
(1 missing value generated)
(1 real change made)
(1 missing value generated)
(1 real change made)
(1 missing value generated)
(1 real change made)
..
.
We never had to generate a constant. Why here?
p
The constant needs to be scaled by (1 − ρ) or 1 − ρ2 .
The first three columns are all based on OLS. Only the standard errors differ.
The fourth column is based on FGLS, so the point estimates differ as well.