Page 2 of 2

Re: VARLAGSELECT—Automatic lag selection in a VAR

Posted: Sat Apr 23, 2016 6:13 pm
by zw83189
Hello Tom, Can I use @varlagselect on VARX model?

Re: VARLAGSELECT—Automatic lag selection in a VAR

Posted: Sun Apr 24, 2016 9:38 am
by TomDoan
zw83189 wrote:Hello Tom, Can I use @varlagselect on VARX model?
No. But the VARLAG.RPF program shows how the calculations are done within @VARLAGSELECT and you can adjust the VAR within that to include the "X" variables.

Re: VARLAGSELECT—Automatic lag selection in a VAR

Posted: Mon Apr 25, 2016 12:17 am
by zw83189
Thanks Tom.
Thanks for your reply. Do I just need to change the endogenous variables/data period and include the exogenous variables in deterministic option, and keep the rest the same?

For the deterministic option, I put " det constant lhashbtc dlb dtb*lhashbtc ". Where lhashbtc is my exogenous variable and dlb is the intercept dummy, dtb is the trend dummy.

I tried the following code but an error message showed up.



Code: Select all

system(model=varmodel)
variables logrbtc logrltc
lags 1
det constant volbtc volltc tranbtc tranltc lwikibtc lwikiltc lhashbtc lhashltc dll dtb*lhashbtc 
end(system)

report(action=define,hlabel=||"Lags","AIC","SBC","LR Test","P-Value"||)
dec real lastll

do lags=1,8
   system(model=varmodel)
   variables logrbtc logrltc
   lags 1 to lags
   det constant lhashbtc lhashltc dlb dtb*lhashbtc
   end(system)
   estimate
   compute ll =%logl
   compute sbc=-2.0*ll/%nobs+%nregsystem*log(%nobs)/%nobs
   compute aic=-2.0*ll/%nobs+%nregsystem*2.0*%nvar/(%nvar*%nobs-%nregsystem-1)
   report(row=new,atcol=1,align=decimal) lags aic sbc
   if lags>1
      report(row=current,atcol=4) 2*(ll-lastll) %chisqr(2*(ll-lastll),%nvar*%nvar)
   compute lastll=ll
end do lags

report(action=format,atcol=2,tocol=2,special=onestar,tag=min,align=decimal)
report(action=format,atcol=3,tocol=3,special=onestar,tag=min,align=decimal)
report(action=format,atcol=2,tocol=3,width=8)
report(action=format,atcol=4,tocol=5,picture="*.####")
report(action=show)
## SR3. Tried to Use Series Number 195, Only 19 Are Available

Re: VARLAGSELECT—Automatic lag selection in a VAR

Posted: Mon Apr 23, 2018 3:41 pm
by TomDoan
You can't use dtb*lhashbtc in a regressor list. Do a separate SET instruction for the interaction, that is, something like

set combo = dtb*lhashbtc

and then

det constant lhashbtc lhashltc dlb combo

Re: VARLAGSELECT—Automatic lag selection in a VAR

Posted: Tue Apr 02, 2019 1:47 pm
by ateeb
@varlagselect(crit=AIC,signif=0.05,lags=12) 2003:07 2018:09
# DiffX1 DiffX2 DiffX3 logX4 X5

So in the model i am trying to run there is one cointegrating vector, furthermore the sample starts from 2002:06 and for ADF tests I had to difference the variables once. So my question is that given the command above, the procedure will run the models and minimize the criteria using an estimation period from 2003:07 to 2018:09 and will pick lags 1 through 12 starting from 2002:07 to 2003:06?

Right?

Regards,

Ateeb Syed

Re: VARLAGSELECT—Automatic lag selection in a VAR

Posted: Tue Apr 02, 2019 2:50 pm
by TomDoan
The SIGNIF option doesn't matter because the CRIT=AIC controls. If you're trying to use the full sample at the start, simply use * 2018:9 as the range. (Or if you want to use the maximum possible data, just skip the range entirely). As written it will use entries from 2003:7 to 2018:9, which means data to give 12 lags from 2002:8 on.

Note that if the series are cointegrated, you should pick the lags on the levels, not the differences. And while it won't happen with levels on cointegrated series (or any I(1) series), the number of lags will be chosen from 0 to 12, not 1 to 120.

Re: VARLAGSELECT—Automatic lag selection in a VAR

Posted: Tue Apr 02, 2019 6:39 pm
by ateeb
Thank you,

it means i should use

@varlagselect(Crit=AIC,lags=12) 2003:07 2018:09
# Logdebt LogCPI LogM1 LogLSM R

Actually Logdebt, LogCPI and LogM1 are cointegrated and LogLSM and R are stationary in levels. so am i doing it right? my original sample is 2002:06 to 2018:09. so it will pick 12 lags starting from 2002:07 right? you stated 2002:08 in last comment but does'nt that mean 2002:08 to 2003:06 11 lags because i want my estimation period to be same for all estimations?

Thanks for responding quickly.

Re: VARLAGSELECT—Automatic lag selection in a VAR

Posted: Tue Apr 02, 2019 9:21 pm
by TomDoan
All the VAR estimates use the same set of entries (the AIC's aren't comparable otherwise). You seem to be overthinking the range issue. Unless you have a reason to do differently, you should leave the range empty and let it be the maximum allowed by the data allowing for 12 lags.

Re: VARLAGSELECT—Automatic lag selection in a VAR

Posted: Wed Apr 03, 2019 10:30 am
by ateeb
Thanks for your reply. Appreciate that. I am a PhD candidate and at the moment learning VARs in the best manner possible, hope my questions are not annoying you. Actually when i did my ADF tests in levels i used augmented dickey fuller test, it needs first difference on the left hand side and lagged differences on left hand side. So when my original data started from 2002:06 with 1 differencing and then allowing for 12 lags my estimation started from 2003:07. I am concerned about this because if that estimation started from 2003:07 all other estimations should have the same period as well otherwise the results would not be consistent.

So that is why i am taking care about it, i am not overthinking but i want to be accurate on what i learned and what i apply.

I await your response. Thanks in advance.

Regards,

Ateeb Syed

Re: VARLAGSELECT—Automatic lag selection in a VAR

Posted: Wed Apr 03, 2019 11:00 am
by TomDoan
In the unit root/cointegration literature there are two ways to count lags: the number of lags on the differences (augmenting lags) or the number of lags in the reduced form AR/VAR (what you get when you substitute back to levels). The first will be one less than the second. Both CATS and the RATS @JOHMLE procedure for doing cointegration use the second method, and @VARLAGSELECT on the levels is a consistent method of choosing the lag length for the cointegrated model.

You're correct that using (up to) 12 lags on the differences in an ADF test is really using 13 lagged values, and the similar analysis on @VARLagSelect will use 13 lags. However, you don't have to use the same number of lags in those; a univariate test can safely use more lags than a multivariate one because the latter can run into degrees of freedom issues.

Re: VARLAGSELECT—Automatic lag selection in a VAR

Posted: Fri Jan 03, 2020 10:57 pm
by widad
Hallo Tom Doan!

I want to apply the example suggested with the @VarLagSelect procedure but I can't find a file called "GSCI_gold_and_silver.xlsx" in the Rats pack.

thank you for your help,

Widad

Re: VARLAGSELECT—Automatic lag selection in a VAR

Posted: Sat Jan 04, 2020 12:16 pm
by TomDoan
That is from the FVO2P254.RPF example in the Franses-Van Dijk-Opschoor textbook examples.

Re: VARLAGSELECT—Automatic lag selection in a VAR

Posted: Sun Jan 05, 2020 2:08 pm
by PeterF
TomDoan wrote:That is from the FVO2P254.RPF example in the Franses-Van Dijk-Opschoor textbook examples.
Dear Tom,

where can I find these textbook examples? I neither could find them in the textbook examples sub-director of RATS version 10 nor at the estima website.

Best regards
PeterF