BVARs yet again

For questions about EViews Add-ins available from the EViews Add-ins webpage. Note each add-in available on our webpage will have its own individual thread.

Moderators: EViews Gareth, EViews Moderator, EViews Esther

donihue
Posts: 135
Joined: Wed Oct 07, 2009 8:51 am

BVARs yet again

Postby donihue » Sun Mar 20, 2011 8:34 am

I apologise for once again returning to this subject!

The GUI works perfectly, but I am having problems using the command-line interface for this excellent Add-in (I want to use a loop to calculate a range of models over different sets of hyperparameters).

According to the .pdf file for this Add-in, 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 Esther
EViews Developer
Posts: 149
Joined: Fri Sep 03, 2010 7:57 am

Re: BVARs yet again

Postby EViews Esther » Tue Mar 22, 2011 11:50 am

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 :cry: ).

When you re-install the BVAR addin, you will see the updated command options.

donihue
Posts: 135
Joined: Wed Oct 07, 2009 8:51 am

Re: BVARs yet again

Postby donihue » Wed Mar 23, 2011 2:57 am

Many thanks, Esther - it works fine now

regards
Donihue

donihue
Posts: 135
Joined: Wed Oct 07, 2009 8:51 am

Re: BVARs yet again (2)

Postby donihue » Wed Mar 23, 2011 3:17 am

Hello again, Esther,

Any chance of adding a command-line 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 Add-in: it is a real life-saver for we BVAR workers!

Regards
Donihue

mayxanh
Posts: 19
Joined: Sat Feb 12, 2011 12:03 pm

Re: BVARs yet again

Postby mayxanh » Sat Apr 02, 2011 7:27 pm

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

EViews Esther
EViews Developer
Posts: 149
Joined: Fri Sep 03, 2010 7:57 am

Re: BVARs yet again

Postby EViews Esther » Mon Apr 04, 2011 8:11 am

It seems that there exist a singularity problem. Could you upload your workfile? Then, I will figure out the solution.

mayxanh
Posts: 19
Joined: Sat Feb 12, 2011 12:03 pm

Re: BVARs yet again

Postby mayxanh » Mon Apr 04, 2011 7:44 pm

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 non-stationary, 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 485 times

EViews Esther
EViews Developer
Posts: 149
Joined: Fri Sep 03, 2010 7:57 am

Re: BVARs yet again

Postby EViews Esther » Tue Apr 05, 2011 10:52 am

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

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

mayxanh
Posts: 19
Joined: Sat Feb 12, 2011 12:03 pm

Re: BVARs yet again

Postby mayxanh » Tue Apr 05, 2011 8:24 pm

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

mayxanh
Posts: 19
Joined: Sat Feb 12, 2011 12:03 pm

Re: BVARs yet again

Postby mayxanh » Tue Apr 05, 2011 8:55 pm

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13315
Joined: Tue Sep 16, 2008 5:38 pm

Re: BVARs yet again

Postby EViews Gareth » Wed Apr 06, 2011 8:08 am

That's a little outside of the realm of technical support.
Follow us on Twitter @IHSEViews

mayxanh
Posts: 19
Joined: Sat Feb 12, 2011 12:03 pm

Re: BVARs yet again

Postby mayxanh » Thu Apr 07, 2011 5:25 am

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13315
Joined: Tue Sep 16, 2008 5:38 pm

BVARs yet again

Postby EViews Gareth » Thu Apr 07, 2011 6:52 am

No. The BVAR uses Bayesian techniques, as outlined in the documentation.
Follow us on Twitter @IHSEViews

mjfl
Posts: 49
Joined: Mon Jul 18, 2011 8:18 am

Re: BVARs yet again

Postby mjfl » Fri Aug 26, 2011 2:17 am

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13315
Joined: Tue Sep 16, 2008 5:38 pm

Re: BVARs yet again

Postby EViews Gareth » Fri Aug 26, 2011 7:58 am

Once you have the model, just solve the model over the period you wish to forecast.
Follow us on Twitter @IHSEViews


Return to “Add-in Support”

Who is online

Users browsing this forum: No registered users and 20 guests