I have a very simple basic RBC model and i am trying to set it up in dynare. Below is how i have set it up. i, however, get the error - line 39, col 1: syntax error, unexpected INT_NUMBER

@#define use_real_data=0
var c k z c_obs;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// 2. Exogenous variables.
varexo eps;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// 3. Parameters.
parameters beta alpha delta rho sigma_z;
beta = 0.98;
alpha = 0.400;
delta = 1.000;
rho = 0.420;
sigma_z = 1.000;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// 5. Model block
model;
1/c = beta*((1/c(+1))*(1+alpha*(z(+1)*(k(+1)^(alpha-1))- delta)));
z*(k^alpha) + k*(1-delta) = c + k(+1);
z(+1) = (rho*z) + sigma_z*eps;
c_obs = log(c);
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//6. Initial Values
initval;
1/beta = (1+(alpha*(z*(k^alpha))/k)- delta);
z*(k^alpha) = c+(k*delta);
z=1
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// 7. Shocks
shocks;
var eps=0.0068^2;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//check the starting values for the steady state
resid;
// compute steady state given the starting values
steady;
// check Blanchard-Kahn-conditions
check;
//simulate data for estimation
@# if use_real_data==1
stoch_simul(order=1,periods=0) c;
@# else
stoch_simul(order=1,periods=200) c;
datatomfile('data_simulated_bm',[]);
@# endif

Can someone please help in explaining why the syntax error is arising? I will be really grateful.

I solved the above issue and program runs fine now but I had following follow-up questions: am new to dynare and I am using another language for bayesian estimation. I see that my results from dynare do not match my set of codes. I therefore have two following questions:

1)Does Dynare not use Chris Sims gensys as a default program to solve the model? Since I use gensys that might be the reason for discrepancy?

Also, I use a standard Kalman Filter - multivariate Kalman Filter algorithm, which is commonly used for state estimation in linear dynamic systems with Gaussian noise. In order to generate the initial state mean, I sample from a multivariate normal distribution with mean. This variable is initialized as a NumPy array of zeros with a length equal to the number of endogenous variables. Initial state covariance matrix is initialized as an identity matrix with dimensions : (no. of endogenous variable``x``no. of endogenous variables).

Does Dynare default code use above (1) and (2). I am anticipating that because (!) and (2) are not being used, I get different estimation results.

Is there a way I can change some settings in syntax of Estimation command so that (1) and (2) above are used so that I can match my estimation results with dynare? Otherwise, my results will not be comparable.

I am following the example of “RBC_baseline_first_diff_bayesian.mod” for reference in Dynare.

I already went through dynare reference manual and various questions posted on the dynare form but I am still not clear about (1), (2) and (3) above.

Your initval block equation for k is incorrect (most likely wrong bracketing), which explains why it does not run as a steady_state_model-block.#

Dynare does not use gensys. But generally the particular solution technique for the quadratic matrix equation does not matter. All approaches should return results that are numerically very similar except for pathological cases. Most likely there is another issue. Before moving to estimation, you should compare simulation results, i.e. IRFs.

Dynare uses a different initialization by default, namely the unconditional mean (i.e. the steady state) and the unconditional variance (the solution of the Lyapunov equation).

Sorry, I don’t have time to check users’ linearizations. But particularly the second equation looks incorrect. In additive equations, there will be pre-factors as the steady states will not cancel.

Sure, I understand Prof. Pfeifer. I corrected my equations. Also, I am trying the estimation in python and there I have put in place a system where I put in both - simply model equations and also the log-linearized equations to check solutions from both. So, I need log-linearization for my python codes, not dynare.

Basically, the whole purpose of getting to dynare is checking my computations from python with dynare results. Even though the algorithms might be different, the answers should match and currently, my answers do not match for both. Log-likelihood value varies and the posterior mean estimations are not very close which they should be.

Also, is there a way I can just see Kalman Filter codes that dynare uses. I guess to see the likelihood value, I compared the value"initial value of log-likelihood" before csminwel starts optimization. I am comparing that to my log-likelihood which I obtain from Python estimation to this initial value of log-likelihood. Since they differe given same initial parameter values I wanted to check dynare’s Kalman Filter with that what I use, to cross-check.

This first check always is whether the IRFs to shocks at the initial parameter values is the same across programs. The second step is then to simulate the model variables and check the mean and standard deviation of the implied observables. Particularly the mean needs to be consistent with the one in actual data.

Thank you Prof. Pfeifer. I have checked irf - at the initial parameter values it is the same across programs. The moments of the simulated data are not same across python and dynare.

Can I just access the Kalman Filter codes (Matlab or C) which dynare uses - a comparison might be good?
I had earlier compared the output from gensys (I know dynare does not use gensys) from MATLAB and python and they match exactly.

So, my observable is just k in so both in python and dynare i define just k as observable. For python it is defined as kt/kss, while it is just varobs k with my simple RBC set-up which you corrected previously.

Thank you for sharing the kalman filter codes. I really appreciate your help. I really want to get to the bottom of the reason which creates a difference in the results.