Dsge__var

Hi,
I am trying to do the following example. the new is the estimation of a dsge_var model defining the dsge_prior_weight as a parameter, but it doesn’t work.

// .mod file for estimating model

var pi, y, r, pie, epspi, epsy, epsr, epspie, inflobs, outputobs, ffrobs, pieobs; % endogenous variables and exogenous latent AR(1)processes
varexo eepspi, eepsy, eepsr, eepspie; % shocks

parameters beta, alpha, dsge_prior_weight, gamma, k, h, tau, phipi, phiy, phir, rhopi, rhor, rhoy, rhopie;

//initial values for the parameter vector
//quarterly data(no annualization)

//fixed/steady state parameters
beta = 0.99;
rhopi=0.6;

//structural model
alpha=1;
k=0.05;
h=0.9;
tau=0.15;
phipi=1.5;
phiy=0.25;
phir=0.9;
rhopi=0.6;
rhor=0.5;
rhoy=0.5;
rhopie=0.5;
gamma=0.5;

model;
// state space
pi=beta*(gammapi(1)+(1-gamma)pie)+ky+epspi;
y=(1/(1+h))y(1)+(h/(1+h))y(-1)-tau(r-pi(1))+epsy;
pie=rhopie
pie(-1)+alpha
y(-1)+epspie;
r=(1-phir)(phipipi+phiyy)+phirr(-1)+epsr;
epspi=rhopiepspi(-1)+eepspi;
epsy=rhoy
epsy(-1)+eepsy;
epsr=rhorepsr(-1)+eepsr;
epspie=rhopie
epspie(-1)+eepspie;

//measurement equation
inflobs=pi;
outputobs=y;
ffrobs=r;
pieobs=pie;
end;

steady(solve_algo=0);check;

estimated_params;
dsge_prior_weight, beta_pdf,0.5,0.4;
beta, beta_pdf, 0.4,0.1;
alpha, beta_pdf, 0.9,0.03;
gamma, beta_pdf, 0.5,0.2;
k, 0.04,gamma_pdf,0.1,0.02;
h, 0.62,beta_pdf,0.5,0.1;
tau, 0.10,gamma_pdf,0.1,0.05;
phipi,1.99, normal_pdf,1.5,0.2;
phiy,0.15,gamma_pdf,0.3, 0.2;
phir, 0.75,beta_pdf,0.5,0.2;
rhopi,0.5,beta_pdf,0.6,0.1;
rhor,0.5,beta_pdf,0.6,0.1;
rhoy,0.5,beta_pdf,0.6,0.1;
rhopie,0.5,beta_pdf,0.6,0.1;
//shocks,stdevs
stderr eepspi,0.10,inv_gamma_pdf,0.3,2;
stderr eepsy,0.50,inv_gamma_pdf,0.3,2;
stderr eepsr,0.22,inv_gamma_pdf,0.3,2;
stderr eepspie,0.25,inv_gamma_pdf,0.3,2;
end;

varobs inflobs outputobs ffrobs pieobs;//
//sample: 1982q1-2012q2

estimation(datafile=fyhu4_data,prefilter=1,first_obs=1, mode_compute=4,mode_check,mh_replic=0);% ycbo seems to work better
estimation(datafile=fyhu4_data,prefilter=1,first_obs=1,conf_sig=0.90,mh_nblocks=5,mh_jscale=0.2,mh_drop=0.5,mode_compute=4,mode_check,bayesian_irf,filtered_vars,forecast=40,mh_replic=200000); % ycbo seems to work better

The response of Matlab is:

VarSampleMoments :: not enough data to initialize! Try to increase FirstObservation.
Error using +
Matrix dimensions must agree.

Error in dsge_var_likelihood (line 200)
tmp0 =
dsge_prior_weightDynareDataset.info.ntobsTheoreticalAutoCovarianceOfTheObservedVariables(:,:,1)
+ mYY ;

Error in initial_estimation_checks (line 47)
[fval,junk1,junk2,a,b,c,d] =
feval(objective_function,xparam1,DynareDataset,DynareOptions,Model,EstimatedParameters,BayesInfo,DynareResults);

Error in dynare_estimation_1 (line 179)
oo_ =
initial_estimation_checks(objective_function,xparam1,dataset_,M_,estim_params_,options_,bayestopt_,oo_);

Error in dynare_estimation (line 89)
dynare_estimation_1(var_list,dname);

Error in an (line 230)
dynare_estimation(var_list_);

Error in dynare (line 180)
evalin(‘base’,fname) ;

Please post the datafile. Which Dynare version are you using?

I am using dynare 4.4.0. Her is the data file
fyhu4_data.m (13.5 KB)

Sorry, it’s a dynare 4.4.3

The VAR-part has 4 lags that need to be initialized using a training sample. When you specify

you are telling Dynare to use observation -3 to 0 which do not exist. Thus, Dynare tells you to use at least

When you change this, everything should work.

ok, thanks it works.

Hi, I have 2 questions.
Firts, which of the solid and dashed lines corrisponds to dsge and vars(sorry, it’s the first time that i’m trying a dsge_var estimation)?

Second, why this model works with dsge_var estimation but when I try the model whithout dsge_var it doesn’t work?

  1. See Pfeifer (2014): An Introduction to Graphs in Dynare at sites.google.com/site/pfeiferecon/dynare
  2. You need to be more precise. What is the problem?

The problem is that comes out the priors and mode check plots and then stop runing:

Error using chol
Matrix must be positive definite.

Error in metropolis_hastings_initialization (line 68)
d = chol(vv);

Error in random_walk_metropolis_hastings (line 62)
ix2, ilogpo2, ModelName, MetropolisFolder, fblck, fline, npar, nblck, nruns, NewFile, MAX_nruns, d ]
= …

Error in dynare_estimation_1 (line 782)
feval(options_.posterior_sampling_method,objective_function,options_.proposal_distribution,xparam1,invhess,bounds,dataset_,options_,M_,estim_params_,bayestopt_,oo_);

Error in dynare_estimation (line 89)
dynare_estimation_1(var_list,dname);

Error in fusa21 (line 270)
dynare_estimation(var_list_);

Error in dynare (line 180)
evalin(‘base’,fname) ;

Search the forum on this one. There are dozens of posts on this.