BVARs yet again
Moderators: EViews Gareth, EViews Moderator, EViews Esther
BVARs yet again
I apologise for once again returning to this subject!
The GUI works perfectly, but I am having problems using the commandline interface for this excellent Addin (I want to use a loop to calculate a range of models over different sets of hyperparameters).
According to the .pdf file for this Addin, the command line should read (as an example) "bvar(Prior=0) gdp interest inflation", with other options available, such as L0, L1, etc
I have tried
bvar(Prior=0) mb gdp usd_rate cpi
bvar(Prior=0,L0=0.8,L1=0.1,L3=2,L4=1,L5=0.07,Mu5=0.1,Mu6=0.1,QM=12) mb gdp usd_rate cpi
bvar(Prior=0 L0=0.8 L1=0.1 L3=2 L4=1 L5=0.07 Mu5=0.1 Mu6=0.1 QM=12) mb gdp usd_rate cpi
bvar(Prior=0,lambda0=0.8,lambda1=0.1,lambda3=2,lambda4=1,mu5=0.1,mu6=0.1,qm=12) mb gdp usd_rate cpi
but in all cases, received the cryptic message "Syntax error".
This clearly indicates that I am doing something obviously wrong in formulating the command, but I cannot see what. Can you help, please?
Regards
Donihue
The GUI works perfectly, but I am having problems using the commandline interface for this excellent Addin (I want to use a loop to calculate a range of models over different sets of hyperparameters).
According to the .pdf file for this Addin, the command line should read (as an example) "bvar(Prior=0) gdp interest inflation", with other options available, such as L0, L1, etc
I have tried
bvar(Prior=0) mb gdp usd_rate cpi
bvar(Prior=0,L0=0.8,L1=0.1,L3=2,L4=1,L5=0.07,Mu5=0.1,Mu6=0.1,QM=12) mb gdp usd_rate cpi
bvar(Prior=0 L0=0.8 L1=0.1 L3=2 L4=1 L5=0.07 Mu5=0.1 Mu6=0.1 QM=12) mb gdp usd_rate cpi
bvar(Prior=0,lambda0=0.8,lambda1=0.1,lambda3=2,lambda4=1,mu5=0.1,mu6=0.1,qm=12) mb gdp usd_rate cpi
but in all cases, received the cryptic message "Syntax error".
This clearly indicates that I am doing something obviously wrong in formulating the command, but I cannot see what. Can you help, please?
Regards
Donihue

 EViews Developer
 Posts: 149
 Joined: Fri Sep 03, 2010 7:57 am
Re: BVARs yet again
It was my bad. The first argument should be the number of lags.
For example, you can say:
bvar(Prior=0) 2 mb gdp usd_rate cpi
(Note: "bvar(Prior=0) mb gdp usd_rate cpi" will report the error message ).
When you reinstall the BVAR addin, you will see the updated command options.
For example, you can say:
bvar(Prior=0) 2 mb gdp usd_rate cpi
(Note: "bvar(Prior=0) mb gdp usd_rate cpi" will report the error message ).
When you reinstall the BVAR addin, you will see the updated command options.
Re: BVARs yet again
Many thanks, Esther  it works fine now
regards
Donihue
regards
Donihue
Re: BVARs yet again (2)
Hello again, Esther,
Any chance of adding a commandline option to produce a model, as in the GUI?
Given the lack of a direct forecast command for BVARs (as also for VECMs) this is essential for forecasting.
Again, many thanks for your work on this Addin: it is a real lifesaver for we BVAR workers!
Regards
Donihue
Any chance of adding a commandline option to produce a model, as in the GUI?
Given the lack of a direct forecast command for BVARs (as also for VECMs) this is essential for forecasting.
Again, many thanks for your work on this Addin: it is a real lifesaver for we BVAR workers!
Regards
Donihue
Re: BVARs yet again
Hi Esther,
I have just installed BVAR and use the exact command that you shown above. However, there is an error message keeping poping up: "_SH01 is not defined" Could you please to explain me why? Thank you very much.
T
I have just installed BVAR and use the exact command that you shown above. However, there is an error message keeping poping up: "_SH01 is not defined" Could you please to explain me why? Thank you very much.
T

 EViews Developer
 Posts: 149
 Joined: Fri Sep 03, 2010 7:57 am
Re: BVARs yet again
It seems that there exist a singularity problem. Could you upload your workfile? Then, I will figure out the solution.
Re: BVARs yet again
Esther,
Thank you for your assistance. I upload the workfile named test.
When I run the following command:
bvar(Prior=0) 2 LOG_IRR_SA_CA LOG_CCLI_S IR_SPREAD_U LOG_GDP_CHN_SA LOG_CPI_TOTAL_S LOG_CERI_S
The error message is "_SH01 is not defined"
When I run the command:
bvar(Prior=0,m=model) 2 LOG_IRR_SA_CA D(LOG_CCLI_S) D(IR_SPREAD_U) D(LOG_GDP_CHN_SA) D(LOG_CPI_TOTAL_S) D(LOG_CERI_S)
(because all series are nonstationary, except LOG_IRR_SA_CA)
then the model is estimated without any error message. However, there are a series of error messages inside the model object:
"syntax error in ..."
I need to get the model object in order to do the forecasting using rolling windows.
Thank you again
Thank you for your assistance. I upload the workfile named test.
When I run the following command:
bvar(Prior=0) 2 LOG_IRR_SA_CA LOG_CCLI_S IR_SPREAD_U LOG_GDP_CHN_SA LOG_CPI_TOTAL_S LOG_CERI_S
The error message is "_SH01 is not defined"
When I run the command:
bvar(Prior=0,m=model) 2 LOG_IRR_SA_CA D(LOG_CCLI_S) D(IR_SPREAD_U) D(LOG_GDP_CHN_SA) D(LOG_CPI_TOTAL_S) D(LOG_CERI_S)
(because all series are nonstationary, except LOG_IRR_SA_CA)
then the model is estimated without any error message. However, there are a series of error messages inside the model object:
"syntax error in ..."
I need to get the model object in order to do the forecasting using rolling windows.
Thank you again
 Attachments

 test.WF1
 (18.03 KiB) Downloaded 385 times

 EViews Developer
 Posts: 149
 Joined: Fri Sep 03, 2010 7:57 am
Re: BVARs yet again
Let me clarify the problem first. Since the given regressors are perfectly collinear, the prior values for the residual covariance cannot be calculated.
Following the paper (Sims and Zha; 1998), the current addin calculates the diagonal elements of the prior for the residual covariance matrix S (see Equation 10 in the documentation) by OLS steps.
For example, the 1st diagonal element of S for the 1st lag of LOG_CCLI_S is derived by
When you have perfect collinearity problem in OLS steps, the prior for the residual covariance cannot be calculated.
I think that the solution to your problem can be resolved by changing the prior calculation steps. For example,
Following the paper (Sims and Zha; 1998), the current addin calculates the diagonal elements of the prior for the residual covariance matrix S (see Equation 10 in the documentation) by OLS steps.
For example, the 1st diagonal element of S for the 1st lag of LOG_CCLI_S is derived by
Code: Select all
!m = 3 'number of variables
matrix(!m,!m) S 'storage for S
equation EQ1.ls D(LOG_CCLI_S) D(LOG_CCLI_S)(1) c 'Do OLS: LOG_CCLI_S on D(LOG_CCLI_S)(1) and c only.
!SSR = EQ01.@ssr
s(1,1) = !SSR/EQ1.@regobs
When you have perfect collinearity problem in OLS steps, the prior for the residual covariance cannot be calculated.
I think that the solution to your problem can be resolved by changing the prior calculation steps. For example,
Code: Select all
equation EQ1.ls LOG_IRR_SA_CA D(LOG_CCLI_S) D(IR_SPREAD_U) D(LOG_GDP_CHN_SA) D(LOG_CPI_TOTAL_S) D(LOG_CERI_S) c
'Do OLS: all regressors are used
matrix S = EQ1.@coefcov
Re: BVARs yet again
Hi Esther,
Thank you for your explanation. Regarding the problem with the makemodel, I find out that the problem arise from the usage of D(x)(1) as the variable so that the @word function does not return the correct word. It first returns D(x) then (1) instead of returning the whole string D(x)(1).
I wrote a fix for the subroutine eqmake and this time it works perfectly.
subroutine local eqmake(string %spec, string %coefs, string %speceq)
%speceq = ""
!start = 1
!length = @LENGTH(%spec)
!end = 1
for !i=1 to @wcount(%coefs)
'%word = @word(%spec,!i)
!end = @INSTR (%spec, " ", !i)
if !end =0 or !end = !length then
!end = !length + 1
endif
!size = !end  !start
%word = @MID(%spec, !start, !size)
if @upper(%word) = "C" then 'constant
%word = ""
endif
%coef = @word(%coefs,!i)
if @val(@word(%coefs,!i))>=0 then
%speceq = %speceq+"+"+%coef+"*"+%word
else
%coef=@right(%coef,@len(%coef)1)
%speceq = %speceq+""+%coef+"*"+%word
endif
!start = !end + 1
next
if @val(@word(%coefs,1))>=0 then
%speceq = @right(%speceq,@len(%speceq)1)
endif
%speceq = @left(%speceq,@len(%speceq)1)
endsub
Thank you for your explanation. Regarding the problem with the makemodel, I find out that the problem arise from the usage of D(x)(1) as the variable so that the @word function does not return the correct word. It first returns D(x) then (1) instead of returning the whole string D(x)(1).
I wrote a fix for the subroutine eqmake and this time it works perfectly.
subroutine local eqmake(string %spec, string %coefs, string %speceq)
%speceq = ""
!start = 1
!length = @LENGTH(%spec)
!end = 1
for !i=1 to @wcount(%coefs)
'%word = @word(%spec,!i)
!end = @INSTR (%spec, " ", !i)
if !end =0 or !end = !length then
!end = !length + 1
endif
!size = !end  !start
%word = @MID(%spec, !start, !size)
if @upper(%word) = "C" then 'constant
%word = ""
endif
%coef = @word(%coefs,!i)
if @val(@word(%coefs,!i))>=0 then
%speceq = %speceq+"+"+%coef+"*"+%word
else
%coef=@right(%coef,@len(%coef)1)
%speceq = %speceq+""+%coef+"*"+%word
endif
!start = !end + 1
next
if @val(@word(%coefs,1))>=0 then
%speceq = @right(%speceq,@len(%speceq)1)
endif
%speceq = @left(%speceq,@len(%speceq)1)
endsub
Re: BVARs yet again
Hi Esther,
Another question I would like to ask is how to select the lag length for a BVAR? In a VAR system, we can use Information criterion to automatically select the lag length. How's about BVAR?
Thank you
Another question I would like to ask is how to select the lag length for a BVAR? In a VAR system, we can use Information criterion to automatically select the lag length. How's about BVAR?
Thank you

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 12884
 Joined: Tue Sep 16, 2008 5:38 pm
Re: BVARs yet again
That's a little outside of the realm of technical support.
Follow us on Twitter @IHSEViews
Re: BVARs yet again
Hi Gareth, Esther,
Thanks a lot for your help. Another question I would like to ask is that you use OLS to estimate the BVAR? The VAR system is also estimated by OLS? Thanks again.
Thanks a lot for your help. Another question I would like to ask is that you use OLS to estimate the BVAR? The VAR system is also estimated by OLS? Thanks again.

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 12884
 Joined: Tue Sep 16, 2008 5:38 pm
BVARs yet again
No. The BVAR uses Bayesian techniques, as outlined in the documentation.
Follow us on Twitter @IHSEViews
Re: BVARs yet again
hi,
im new to BVAR and would like to ask if there is any command to forecast the bvar?
i see that making the model helps but can someone pls enlighten how to forecast the bvar directly or from the model?
i cant understand what is
1) no of forecast period
2) forecast selection
becasue even after trying with or w/o it my workfile remains same without any forecast. pls help as im really trying to learn and though the query sound really silly.
im new to BVAR and would like to ask if there is any command to forecast the bvar?
i see that making the model helps but can someone pls enlighten how to forecast the bvar directly or from the model?
i cant understand what is
1) no of forecast period
2) forecast selection
becasue even after trying with or w/o it my workfile remains same without any forecast. pls help as im really trying to learn and though the query sound really silly.

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 12884
 Joined: Tue Sep 16, 2008 5:38 pm
Re: BVARs yet again
Once you have the model, just solve the model over the period you wish to forecast.
Follow us on Twitter @IHSEViews
Who is online
Users browsing this forum: No registered users and 8 guests