Error Message

The below program generates an error message ‘??? Error: Unexpected MATLAB operator’

Can anyone help?

var k pi c n b g a;
varexo epsilon_g epsilon_a;

parameters alpha beta delta gamma_c gamma_c_tilde eta lambda lambda_p mu_p phi_b phi_g phi_pi psi rho rho_a rho_g theta theta_n theta_t omega sigma_tilde;
alpha = .33;
beta = .99;
delta = .025;
gamma_c = .7;
gamma_c_tilde = .1;
eta = 1;
lambda_p = .5;
mu_p = .2;
phi_b = .33;
phi_g = .1;
phi_pi = 1.5;
psi = .2;
rho = .01;
rho_a = .97;
rho_g = .9;
theta = .75;
theta_n = .27;
theta_t = .07;
sigma_tilde = 0.5;

model (linear);
k = (1-delta+(deltaalpha/(1-gamma_c_tilde)))k(-1) + (delta(1-alpha)/(1-gamma_c_tilde))n(-1) - (deltagamma_c/(1-gamma_c_tilde))c(-1) - (delta/(1-gamma_c_tilde))g(-1) + (delta/(1-gamma_c_tilde))a(-1);
pi = (pi(-1) - lambda_p
c(-1) + lambda_p
alpha
k(-1) - (alpha + psi)lambda_pn(-1) + lambda_p
a(-1)) / beta;
c = c(-1) - theta_nn(-1) + theta_nphi_bb(-1) - (phi_pi/sigma_tilde)pi(-1) - (1/sigma_tilde)pi + theta_nn - theta_tphi_bb - theta_tphi_g(rho_g - 1)*g(-1);
n = ( (1-alpha)n - gamma_cc(-1) - (1-gamma_c_tilde)k(-1) + ((1-gamma_c_tilde)etaphi_pi)pi(-1) - (omega-(betagamma_c))c + (omega+beta(1-gamma_c_tilde-alpha))k - ((1-gamma_c_tilde)eta)pi - (1-(betarho_g))g(-1) + (1-(betarho_a))a(-1) ) / (omega(1+psi)+beta(1-alpha));
b = (1 + rho)
(1 - phi_b)b(-1) + (1 + rho)(1 - phi_g)g(-1);
g = rho_g
g(-1) + epsilon_g;
a = rho_a
a(-1) + epsilon_a;
end;

initval;
k = 9;
pi = 1;
c = .76;
n = .3;
b = .76;
a = 1;
g = 0;
end;

steady;

shocks;
var a = .007;
var g = .005;
end;

stoch_stimul;

Hi,
I do not get this error message with your program. Could you please post the mod-file as a file. Note also that you did not define/initialize the parameter omega.

Thanks, you are correct. I pasted the wrong file (the original also did not initialize lampda_p but neither is used in the model block) but the attached file is the correct one. It still generates the same error message. The full error message, if it helps, is…

??? Error: Unexpected MATLAB operator.

Error in ==> dynare at 132
evalin(‘base’,fname) ;

Also, I am using v4.1.1
model.mod (1.66 KB)

You have no variables a and g, so use:

shocks; var epsilon_a = .007; var epsilon_g = .005; end;

stoch_stimul should be stoch_simul.

The lambda in line 25

is not defined/should be lambda_p.

Thank you J. I had assumed that once I got through the preprocessor, I would no longer have syntax errors, but that is clearly not the case. However, having fixed those two problems, I still receive the same error message. I am now going through the code completely once again to check for missing parentheses, etc. However, can anyone tell me what the error message

??? Error: Unexpected MATLAB operator.

Error in ==> dynare at 132
evalin(‘base’,fname) ;

typically means?

I don’t know what is happening here, but the code you posted did not go through the preprocessor on my machine. And I never got the error you mention.

Did you probably use any special characters or spaces when naming your mod-file? This might yield the error.

Thank you for continuing to try to help. Just to clarify, I am using Dynare 4.1.1 in MatLab version 7.8.0 for students (R2009a). The full error message I receive is

EDU>> dynare y:\test.mod

Configuring Dynare …
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.

Starting Dynare (version 4.1.1).
Starting preprocessing of the model file …
Found 7 equation(s).
Evaluating expressions…done
Computing static model derivatives:

  • order 1
    Computing dynamic model derivatives:
  • order 1
  • order 2
    Processing outputs …done
    Preprocessing completed.
    Starting MATLAB/Octave computing.

??? Error: Unexpected MATLAB operator.

Error in ==> dynare at 132
evalin(‘base’,fname) ;

I rewrote the file from scratch just to check my work and have attached it. Thanks again!
test.mod (1.66 KB)

I found your problem. Do not use

dynare y:\test.mod
Rather set your working directory to y:\ and use

dynare test.mod
The reason is that if you use the first command, Dynare tries to execute y:\test.m in line 132, but : and \ are reserved for math operations if not given to Matlab as a string path.

Note that there again is the problem that you have no variables a and g, so use:

shocks; var epsilon_a = .007; var epsilon_g = .005; end;

Thanks very much! This has my program running though I now have issues with my initial values but I can work on that. Also, when I retyped the program I apparently mistyped the shocks section. Thanks for catching that, as well!