VARLAGSELECT—Automatic lag selection in a VAR

Use this forum to post complete RATS "procedures". Please be sure to include instructions on using the procedure and detailed references where applicable.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

VARLAGSELECT—Automatic lag selection in a VAR

Post by TomDoan »

@VARLagSelect is a procedure for selecting the lag length in a VAR using one of several techniques.

Detailed description

Example

This looks at the lag lengths picked using general-to-specific, AIC and SBC to examine the sensitivity to the criterion used.

Code: Select all

*
* Enders, Applied Econometric Time Series, 3rd edition
* Example from Section 5.13
* SVAR example
* Pages 344-347
*
open data realrates.xls
calendar(q) 1973:1
data(format=xls,org=columns) 1973:01 2008:02 e_can e_ja e_uk p_ca p_ja p_uk p_us
*
set loge_uk  = log(e_uk)
set logr_uk  = loge_uk-log(p_uk)+log(p_us)
set dloge_uk = loge_uk-loge_uk{1}
set dlogr_uk = logr_uk-logr_uk{1}
*
linreg dloge_uk
# constant loge_uk{1} dloge_uk{1}
*
* The Elliott-Rothenberg-Stock test can be done using the ERSTEST
* procedure. The DF t statistic is the DFGLS value in the output.
*
@erstest(lags=1) loge_uk
*
* The VARLAGSELECT procedure can help choose the lag length. This does
* general-to-specific, which involves block likelihood ratio tests of
* the final lag.
*
@varlagselect(crit=gtos,lags=8)
# dlogr_uk dloge_uk
@varlagselect(crit=aic,lags=8)
# dlogr_uk dloge_uk
@varlagselect(crit=sbc,lags=8)
# dlogr_uk dloge_uk
*
system(model=xrates)
variables dlogr_uk dloge_uk
lags 1
det constant
end(system)
*
estimate
errors(model=xrates,steps=8)
errors(model=xrates,factor=%bqfactor(%sigma,%varlagsums),steps=8,labels=||"Real","Nominal"||)
realrates.xls
Data file for example
(41 KiB) Downloaded 1244 times
hasanov
Posts: 46
Joined: Tue May 29, 2012 7:31 pm

Re: VARLAGSELECT - Automatic lag selection in a VAR

Post by hasanov »

Hello Tom,
Thanks for the revised procedure.
Similar aspect:
Is it possible to extend this procedure to VARMA-type models?

Regards,
Akram Hasanov
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: VARLAGSELECT - Automatic lag selection in a VAR

Post by TomDoan »

hasanov wrote:Hello Tom,
Thanks for the revised procedure.
Similar aspect:
Is it possible to extend this procedure to VARMA-type models?

Regards,
Akram Hasanov
Not really. Automatic selection of VARMA(p,q) models is generally not a good idea because once you get beyond p=1, q=1 there are all kinds of problems with lack of identification due to cancellation. Plus, VAR's have a simple closed form calculation for their likelihood, while VARMA's require non-linear optimization for each model combination.
wilshire_li
Posts: 1
Joined: Mon Jan 20, 2014 8:41 pm

Re: VARLAGSELECT - Automatic lag selection in a VAR

Post by wilshire_li »

Hello Tom,

I have read the procedure definition varlagselect.src.

I have a question: what is the formula for the called function %logconcdensity( , ) ? Could please you give me a reference?

Thanks,
Wilshire
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: VARLAGSELECT - Automatic lag selection in a VAR

Post by TomDoan »

wilshire_li wrote: I have read the procedure definition varlagselect.src.

I have a question: what is the formula for the called function %logconcdensity( , ) ? Could please you give me a reference?
See Hamilton, Time Series Analysis, formula 11.1.32.
TG81
Posts: 23
Joined: Fri Oct 15, 2010 8:15 pm

Re: VARLAGSELECT - Automatic lag selection in a VAR

Post by TG81 »

I have a question regarding the GTOS criterion. The selection of optimal lags using the GTOS criterion is very sensitive to the choice of maximum number of lags. How do we select the maximum number of lags and hence how do select the optimal number of lags using GTOS?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: VARLAGSELECT - Automatic lag selection in a VAR

Post by TomDoan »

TG81 wrote:I have a question regarding the GTOS criterion. The selection of optimal lags using the GTOS criterion is very sensitive to the choice of maximum number of lags. How do we select the maximum number of lags and hence how do select the optimal number of lags using GTOS?
All of the criteria have some sensitivity to the maximum lags since it changes the range. However, you're correct that GTOS is more sensitive than other criteria. In general, I wouldn't recommend using it for a VAR. When you apply GTOS to any data which are strongly serially correlated, the final lag (the one you're testing each time) tends to be somewhat more significant because it can pick up any "tail" effects. In other words, lag 7 can seem insignificant when you are trying 8 lags, but can seem significant if you drop lag 8, since it can be picking up whatever small effect there was with lag 8.
COMI
Posts: 24
Joined: Mon Sep 28, 2015 4:12 am

Re: VARLAGSELECT - Automatic lag selection in a VAR

Post by COMI »

Dear Tom,

I want to estimate a bivariate VAR model. AIC criterion selects 3 lags while GTOS selects 19 lags (!!). I estimate model with 3 lags. @MVQstat(lags=5) shows that there are not significant correlations between residuals. Results:

Code: Select all

Multivariate Q(5)=       9.94324
Significance Level as Chi-Squared(20)=       0.96919
But when I look into individual residuals it seems that there are some correlations in residuals and Q-stat (10 lags) confirms it. Here are correlations and Q stat of one of the residuals:

Code: Select all

Autocorrelations
   1         2          3         4        5        6        7        8        9        10
 0.06989    0.00972    0.03921  0.04253  0.01100  0.07579 -0.02973  0.11680  0.00279 -0.01533
   11        12         13        14       15       16       17       18       19       20
-0.01833    0.03702    0.02791  0.04746 -0.00274  0.10696 -0.01198 -0.04423 -0.04134 -0.02651

Ljung-Box Q-Statistics
    Lags  Statistic Signif Lvl
      20     24.350   0.059376

Code: Select all

Autocorrelations
   1         2          3         4        5        6        7        8        9        10
 0.06989    0.00972    0.03921  0.04253  0.01100  0.07579 -0.02973  0.11680  0.00279 -0.01533

Ljung-Box Q-Statistics
    Lags  Statistic Signif Lvl
      10     14.073   0.015151
As you note, correlations coefficients are large in lag 8 ( 0.11680) and lag 16 ( 0.10696).
My question is why @MVQstat(lags=5) dose not show correlation among series?
Should I select 8 lags (or even 19 lags) for estimating the model? (I know that you do not recommend GTOS for VAR lag selection but here are some correlations among series).
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: VARLAGSELECT - Automatic lag selection in a VAR

Post by TomDoan »

You have something like 1000 data points? Are these the data for which you are trying to fit a GARCH model? A test with 5 lags will (for obvious reasons) never pick up correlations at 8 or 16. Is there any reason to think that isolated lags at 8 or 16 are anything more than a statistical fluke? My guess is that if you split the data set in two, you would see the significant lags at 8 and 16 only in one of the two halves---those types of things are generally due to just a few outliers being placed that distance apart.
COMI
Posts: 24
Joined: Mon Sep 28, 2015 4:12 am

Re: VARLAGSELECT - Automatic lag selection in a VAR

Post by COMI »

Thank you very much for the insightful and informative guidance you gave me here in RATS forums. I learned so much from you.
I just excluded first half of the data set and this is the final results from bekk vecm:

Code: Select all

MV-GARCH, BEKK - Estimation by BFGS
Convergence in    79 Iterations. Final criterion was  0.0000000 <=  0.0000100
With Heteroscedasticity/Misspecification Adjusted Standard Errors
Usable Observations                       478
Log Likelihood                      -905.3081

    Variable                        Coeff      Std Error      T-Stat      Signif
************************************************************************************
Mean Model(DLX)
1.  DLX{1}                       -0.469852739  0.072277425     -6.50068  0.00000000
2.  DLX{2}                       -0.042194519  0.071854942     -0.58722  0.55705727
3.  DLY{1}                       0.479989991  0.077901431      6.16150  0.00000000
4.  DLY{2}                       0.152567368  0.076116500      2.00439  0.04502800
5.  Constant                      0.032005787  0.042540470      0.75236  0.45183405
6.  ECT{1}                        0.120494298  0.042808179      2.81475  0.00488153
Mean Model(DLY)
7.  DLX{1}                       -0.135971624  0.073779143     -1.84295  0.06533561
8.  DLX{2}                       -0.095986609  0.071252789     -1.34713  0.17793909
9.  DLY{1}                      -0.015456804  0.080778746     -0.19135  0.84825342
10. DLY{2}                       0.052187982  0.079427821      0.65705  0.51114932
11. Constant                     -0.002793417  0.039845889     -0.07011  0.94410967
12. ECT{1}                        0.049129260  0.035825619      1.37134  0.17026764

13. C(1,1)                        0.264537030  0.064302940      4.11392  0.00003890
14. C(2,1)                        0.282051310  0.074770615      3.77222  0.00016180
15. C(2,2)                       -0.000010973  0.009857068     -0.00111  0.99911180
16. A(1,1)                        0.585947112  0.193703812      3.02496  0.00248662
17. A(1,2)                        0.539532404  0.161717423      3.33627  0.00084912
18. A(2,1)                       -0.181957025  0.317154379     -0.57372  0.56615897
19. A(2,2)                       -0.388020645  0.280421673     -1.38370  0.16644905
20. B(1,1)                        0.845819877  0.103034135      8.20912  0.00000000
21. B(1,2)                       -0.084104770  0.100658332     -0.83555  0.40340978
22. B(2,1)                        0.016585319  0.076773077      0.21603  0.82896405
23. B(2,2)                        0.956960775  0.070549791     13.56433  0.00000000

Multivariate Q(10)=      40.30750
Significance Level as Chi-Squared(34)=       0.21130

Test for Multivariate ARCH
Statistic Degrees Signif
    31.31      27 0.25863
Are the results ok?
A(2,2) is negative but insignificant, does it violate bekk restrictions? ( B(2,2) is relatively large while A(2,2) is insignificant )
Coefficients of DLY equation are all insignificant in conventional level, is any thing wrong with these equation?
I really apologize for asking many questions.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: VARLAGSELECT - Automatic lag selection in a VAR

Post by TomDoan »

That's OK. It's possible that you're missing asymmetry effects. However, what I was talking about was running the GARCH model over the full data set and then checking whether the autocorrelation tests were decidedly different in the two subsamples. I'm guessing they are.
COMI
Posts: 24
Joined: Mon Sep 28, 2015 4:12 am

Re: VARLAGSELECT - Automatic lag selection in a VAR

Post by COMI »

I estimated the model over the full sample (500 observations). Here is autocorrelations of first subsample:

Code: Select all

Autocorrelations
   1         2          3         4        5        6        7        8        9        10
 0.05262   -0.00208   -0.01121  0.00413 -0.01347  0.10828 -0.08242  0.08748 -0.05907 -0.05012
   11        12         13        14       15       16       17       18       19       20
-0.06336   -0.04190    0.01328  0.07142 -0.01358  0.18401 -0.03226 -0.01309 -0.01599 -0.06136

Ljung-Box Q-Statistics
    Lags  Statistic Signif Lvl
      20     21.554   0.088248
And for second subsample:

Code: Select all

Autocorrelations
   1         2          3         4        5        6        7        8        9        10
 0.04604   -0.03539   -0.09742 -0.04935  0.05523 -0.26722 -0.02092  0.24057  0.08222  0.05963
   11        12         13        14       15       16       17       18       19       20
-0.10258    0.11006    0.00843 -0.14619 -0.09568 -0.03929  0.11693 -0.14305 -0.03023 -0.16177

Ljung-Box Q-Statistics
    Lags  Statistic Signif Lvl
      20     16.469   0.285568
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: VARLAGSELECT - Automatic lag selection in a VAR

Post by TomDoan »

Right. And as you can see, there is no systematic tendency for any of those larger autocorrelations to be non-zero. You can't rely on @VARLAGSELECT to pick a lag length in a GARCH setting because the procedures are for homoscedastic residuals. If you have GARCH residuals, the correlations can be thrown off by outliers. Thus you typically pick as small a lag length as seems reasonable.
COMI
Posts: 24
Joined: Mon Sep 28, 2015 4:12 am

Re: VARLAGSELECT - Automatic lag selection in a VAR

Post by COMI »

So, I learned another valuable lesson from you Tom:
If in the second subsample larger correlations suddenly become zero or if the don't follow a systematic trend, we can conclude that we don't need to be worry about them. Am I right?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: VARLAGSELECT - Automatic lag selection in a VAR

Post by TomDoan »

Correct. You would probably be suspicious of them to start. It's one thing to have correlations at lag 12 in monthly data, but correlations at locations that make no economic sense generally aren't "real" as you can confirm by varying the sample.
Post Reply