Page 1 of 2

BVARs yet again

Posted: Sun Mar 20, 2011 8:34 am
by donihue
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

Re: BVARs yet again

Posted: Tue Mar 22, 2011 11:50 am
by EViews Esther
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.

Re: BVARs yet again

Posted: Wed Mar 23, 2011 2:57 am
by donihue
Many thanks, Esther - it works fine now

regards
Donihue

Re: BVARs yet again (2)

Posted: Wed Mar 23, 2011 3:17 am
by donihue
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

Re: BVARs yet again

Posted: Sat Apr 02, 2011 7:27 pm
by mayxanh
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

Re: BVARs yet again

Posted: Mon Apr 04, 2011 8:11 am
by EViews Esther
It seems that there exist a singularity problem. Could you upload your workfile? Then, I will figure out the solution.

Re: BVARs yet again

Posted: Mon Apr 04, 2011 7:44 pm
by mayxanh
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

Re: BVARs yet again

Posted: Tue Apr 05, 2011 10:52 am
by EViews Esther
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

Re: BVARs yet again

Posted: Tue Apr 05, 2011 8:24 pm
by mayxanh
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

Re: BVARs yet again

Posted: Tue Apr 05, 2011 8:55 pm
by mayxanh
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

Re: BVARs yet again

Posted: Wed Apr 06, 2011 8:08 am
by EViews Gareth
That's a little outside of the realm of technical support.

Re: BVARs yet again

Posted: Thu Apr 07, 2011 5:25 am
by mayxanh
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.

BVARs yet again

Posted: Thu Apr 07, 2011 6:52 am
by EViews Gareth
No. The BVAR uses Bayesian techniques, as outlined in the documentation.

Re: BVARs yet again

Posted: Fri Aug 26, 2011 2:17 am
by mjfl
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.

Re: BVARs yet again

Posted: Fri Aug 26, 2011 7:58 am
by EViews Gareth
Once you have the model, just solve the model over the period you wish to forecast.