|
Examples / AR1.RPF |
AR1.RPF is an example of estimation of a model with AR(1) errors, using the AR1 instruction with several different options for handling the serial correlation. It also includes the alternative of estimation of LINREG with HAC standard errors.
(This is an example from textbook, so the data series are just labeled X and Y).
The simple regression
linreg y
# constant x
gives a very low Durbin-Watson, indicating rather strongly serially correlated errors. With such a small D-W, a regression in first differences is one possibility. That is most easily done using AR1 with an input value of RHO=1.0.
ar1(rho=1.0) y
# constant x
Because first differencing zeros out the CONSTANT, the output shows it as a zero coefficient with zero standard error.
There are several options for estimating the \(\rho\). The next two instructions do the "conditional" estimates, which drop the first observation: HILU (grid search) and CORC (iterated).
ar1(method=hilu) y
# constant x
ar1(method=corc) y
# constant x
As one would hope, HILU and CORC give (effectively) identical results. The next instruction does maximum likelihood (MAXL option)
ar1(method=maxl) y
# constant x
which comes in with a somewhat higher value of .95 vs .89. This isn’t an unreasonable difference given that there are only 40 data points, and MAXL can use all of them while CORC can only use 39.
The final set of estimates redoes the least squares regression, but corrects the covariance matrix for HAC standard errors
linreg(robust,lwindow=neweywest,lags=4) y
# constant x
The point estimates are the same as the original LINREG, but the standard errors are quite a bit higher.
Full Program
cal(a) 1959
open data ar1.prn
data(format=prn,org=columns) 1959:1 1998:1
*
* OLS regression
*
linreg y
# constant x
*
* First difference regression. This may be the best choice if the
* autocorrelation coefficient is close to 1. (Note that the
* coefficient on the CONSTANT gets zeroed out, since it's
* eliminated by first differencing).
*
ar1(rho=1.0) y
# constant x
*
* AR1 regression using several methods. HILU and CORC should give
* almost identical answers unless there are multiple roots.
*
ar1(method=hilu) y
# constant x
ar1(method=corc) y
# constant x
ar1(method=maxl) y
# constant x
*
* OLS with Newey-West standard errors. This allows for
* autocorrelation of up to four lags.
*
linreg(robust,lwindow=neweywest,lags=4) y
# constant x
Output
Linear Regression - Estimation by Least Squares
Dependent Variable Y
Annual Data From 1959:01 To 1998:01
Usable Observations 40
Degrees of Freedom 38
Centered R^2 0.9584495
R-Bar^2 0.9573561
Uncentered R^2 0.9990931
Mean of Dependent Variable 85.645000000
Std Error of Dependent Variable 12.956316151
Standard Error of Estimate 2.675532533
Sum of Squared Residuals 272.02202467
Regression F(1,38) 876.5495
Significance Level of F 0.0000000
Log Likelihood -95.0976
Durbin-Watson Statistic 0.1229
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. Constant 29.519254786 1.942346872 15.19773 0.00000000
2. X 0.713659422 0.024104758 29.60658 0.00000000
Regression with AR1 - Estimation by Input Value of Rho
Dependent Variable Y
Annual Data From 1960:01 To 1998:01
Usable Observations 39
Degrees of Freedom 37
Centered R^2 0.9942278
R-Bar^2 0.9940718
Uncentered R^2 0.9998873
Mean of Dependent Variable 86.341025641
Std Error of Dependent Variable 12.344862941
Standard Error of Estimate 0.950490737
Sum of Squared Residuals 33.427007715
Log Likelihood -52.3318
Durbin-Watson Statistic 1.5097
Q(9-1) 7.5923
Significance Level of Q 0.4742690
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. Constant 0.0000000000 0.0000000000 0.00000 0.00000000
2. X 0.7199555154 0.0792433390 9.08538 0.00000000
3. RHO 1.0000000000 0.0000000000 0.00000 0.00000000
Regression with AR1 - Estimation by Hildreth-Lu Search
Dependent Variable Y
Annual Data From 1960:01 To 1998:01
Usable Observations 39
Degrees of Freedom 36
Centered R^2 0.9953392
R-Bar^2 0.9950802
Uncentered R^2 0.9999090
Mean of Dependent Variable 86.341025641
Std Error of Dependent Variable 12.344862941
Standard Error of Estimate 0.865881117
Sum of Squared Residuals 26.991003917
Regression F(2,36) 3843.9763
Significance Level of F 0.0000000
Log Likelihood -48.1615
Durbin-Watson Statistic 1.6040
Q(9-1) 9.2616
Significance Level of Q 0.3207097
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. Constant 45.039294676 6.243781141 7.21346 0.00000002
2. X 0.550888733 0.065886010 8.36124 0.00000000
3. RHO 0.891345256 0.042582756 20.93207 0.00000000
Regression with AR1 - Estimation by Cochrane-Orcutt
Dependent Variable Y
Annual Data From 1960:01 To 1998:01
Usable Observations 39
Degrees of Freedom 36
Centered R^2 0.9953392
R-Bar^2 0.9950802
Uncentered R^2 0.9999090
Mean of Dependent Variable 86.341025641
Std Error of Dependent Variable 12.344862941
Standard Error of Estimate 0.865881117
Sum of Squared Residuals 26.991003939
Regression F(2,36) 3843.9763
Significance Level of F 0.0000000
Log Likelihood -48.1615
Durbin-Watson Statistic 1.6040
Q(9-1) 9.2620
Significance Level of Q 0.3206810
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. Constant 45.040044636 6.244136857 7.21317 0.00000002
2. X 0.550882475 0.065889102 8.36075 0.00000000
3. RHO 0.891351908 0.042582035 20.93258 0.00000000
Regression with AR1 - Estimation by Beach-MacKinnon
Dependent Variable Y
Annual Data From 1959:01 To 1998:01
Usable Observations 40
Degrees of Freedom 37
Centered R^2 0.9949256
R-Bar^2 0.9946513
Uncentered R^2 0.9998892
Mean of Dependent Variable 85.645000000
Std Error of Dependent Variable 12.956316151
Standard Error of Estimate 0.947557352
Sum of Squared Residuals 33.221002591
Log Likelihood -54.2141
Durbin-Watson Statistic 1.5175
Q(10-1) 7.6982
Significance Level of Q 0.5648281
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. Constant 26.673429237 5.103987853 5.22600 0.00000700
2. X 0.724927554 0.058683004 12.35328 0.00000000
3. RHO 0.950664003 0.049938333 19.03676 0.00000000
Linear Regression - Estimation by Least Squares
HAC Standard Errors with Newey-West/Bartlett Window and 4 Lags
Dependent Variable Y
Annual Data From 1959:01 To 1998:01
Usable Observations 40
Degrees of Freedom 38
Centered R^2 0.9584495
R-Bar^2 0.9573561
Uncentered R^2 0.9990931
Mean of Dependent Variable 85.645000000
Std Error of Dependent Variable 12.956316151
Standard Error of Estimate 2.675532533
Sum of Squared Residuals 272.02202467
Log Likelihood -95.0976
Durbin-Watson Statistic 0.1229
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. Constant 29.519254786 4.298313417 6.86764 0.00000000
2. X 0.713659422 0.053380966 13.36917 0.00000000
Copyright © 2025 Thomas A. Doan