Can solve model without var_obs, but not with

I’m just about to run my first estimation code, but I don’t think I’ve incorporated observable variables properly. My model is log-linear and stationary in technology so it should be relatively easy. My code for the simple solution is:

[code]var y pi r u yf uf d z a ;
varexo eps_d eps_z eps_a eps_r;
parameters tau h omega beta eta phi_pi phi_y rho_r rho_d rho_z rho_a
gamma_star pi_star sigma_r sigma_d sigma_z sigma_a;

tau = 1.86;
h = 0.5;
omega = 0.66;
eta = 1.0;
phi_pi = 1.5;
phi_y = 0.5;
rho_r = 0.5;
rho_d = 0.5;
rho_z = 0.5;
rho_a = 0.5;
gamma_star = 0.5;
pi_star = 3.36;
sigma_r = 0.5;
sigma_d = 0.5;
sigma_z = 0.5;
sigma_a = 0.5;
beta = 0.9925;

model;

// equation 5
u - y = u(+1) - y(+1) + r - pi(+1);

// equation 6+7
u = ((1-tau)/(1-betah))(1+betah^2) - hy(-1) - betahy(+1) +
(1/1-betah)d - (betah/1-betah)*d(+1);

// equation 13 (NKPC) – substituting nf for n in the d+eta term.
// Also, C=Y => c=y, from equilibrium condition between 4 and 5
pi = betapi(+1) + ((1-betaomega)(1-omega)/omega)(d + eta*(y-a) - u + y - a)
+ ((1-omega)/omega)(z - betaomega*z(+1));

// equation 16
yf = a + (1/(1+eta))*uf - (1/(1+eta))*d;

// equation 17
uf = ((1-tau)/(1-betah))((1+betah^2)yf - hyf(-1) - betahyf(+1)) +
(1/(1-beta
h))d - ((betah)/(1-beta*h))*d(+1);

// equation 18 (Taylor rule)
r = rho_rr(-1) + (1-rho_r)(phi_pipi + phi_y(y-yf)) + eps_r;

// equations 19-21
d = rho_dd(-1) + eps_d;
z = rho_z
z(-1) + eps_z;
a = rho_a*a(-1) + eps_a;

end;

initval;

y = 0.0;
pi = 0.0;
r = 0.0;
u = 0.0;
yf = 0.0;
uf = 0.0;
d = 0.0;
z = 0.0;
a = 0.0;

end;

check;[/code]

This gives me steady state values of:

```y -0.701275 pi 0.701275 r 0.701275 u -1.43215 yf 0 uf 0 d 0 z 0 a 0```

Next, I want to add the three measurement equations that relate the model variables to the data:

Where s, the vector of model variables is:

I’ve updated my code to include the steady state values of y, pi, r and u and added the three measurement equations above:

[code]var y pi r u yf uf d z a YGR INFLATION INT;
varexo eps_d eps_z eps_a eps_r;
parameters tau h omega r_star eta phi_pi phi_y rho_r rho_d rho_z rho_a
gamma_star pi_star sigma_r sigma_d sigma_z sigma_a;

model;

// defining the transformation of estimated param r_star

beta = exp(r_star/400)^-1;

// equation 5
u - y = u(+1) - y(+1) + r - pi(+1);

// equation 6+7
u = ((1-tau)/(1-betah))(1+betah^2) - hy(-1) - betahy(+1) +
(1/1-betah)d - (betah/1-betah)*d(+1);

// equation 13 (NKPC) – substituting nf for n in the d+eta term.
// Also, C=Y => c=y, from equilibrium condition between 4 and 5
pi = betapi(+1) + ((1-betaomega)(1-omega)/omega)(d + eta*(y-a) - u + y - a)
+ ((1-omega)/omega)(z - betaomega*z(+1));

// equation 16
yf = a + (1/(1+eta))*uf - (1/(1+eta))*d;

// equation 17
uf = ((1-tau)/(1-betah))((1+betah^2)yf - hyf(-1) - betahyf(+1)) +
(1/(1-beta
h))d - ((betah)/(1-beta*h))*d(+1);

// equation 18 (Taylor rule)
r = rho_rr(-1) + (1-rho_r)(phi_pipi + phi_y(y-yf)) + eps_r;

// equations 19-21
d = rho_dd(-1) + eps_d;
z = rho_z
z(-1) + eps_z;
a = rho_a*a(-1) + eps_a;

// equations with observables
YGR = gamma_star + y - y(-1);
INFLATION = pi_star + 4pi;
INT = r_star + pi_star + 4
r;

end;

varobs YGR, INFLATION, INT;

initval;

y = -0.701275;
pi = 0.701275;
r = 0.701275;
u = -1.43215;
yf = 0.0;
uf = 0.0;
d = 0.0;
z = 0.0;
a = 0.0;

end;

check;

estimated_params;
tau, gamma_pdf, 1.86, 0.00053849453622487;
h, beta_pdf, 0.50, 8.04044774925387;
omega, beta_pdf, 0.66, 451.441666380238;
r_star, gamma_pdf, 3.0, 0.0067665251;
eta, gamma_pdf, 1.0, 0.0040000270;
phi_pi, gamma_pdf, 1.50, 0.0004983714;
phi_y, gamma_pdf, 0.50, 0.0000943928;
rho_r, beta_pdf, 0.50, 7.3977015267;
rho_d, beta_pdf, 0.50, 7.3977015267;
rho_z, beta_pdf, 0.50, 7.3977015267;
rho_a, beta_pdf, 0.50, 8.0404477493;
gamma_star, gamma_pdf, 0.50, 10.4443996210;
pi_star, gamma_pdf, 3.36, 0.0620955159;
sigma_r, inv_gamma_pdf, 0.50, 0.0660840873;
sigma_d, inv_gamma_pdf, 0.50, 0.0660840873;
sigma_z, inv_gamma_pdf, 0.50, 0.0660840873;
sigma_a, inv_gamma_pdf, 0.50, 0.0660840873;
end;

estimation(datafile=hirose, mh_replic=50000, mh_nblocks=5);[/code]

only now I’m told that Dynare can’t calculate the steady state.

[code]Starting MATLAB/Octave computing.

STEADY: numerical initial values incompatible with the following equations
2 3 4 5 6 7 8 9 10 11 12

??? Error using ==> dynare_solve at 82
exiting …

Error in ==> steady_ at 124

Error in ==> steady at 52

Error in ==> hirose at 152

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

I’ve tried entering the observables as regular variables to get steady state values in the simple code, which gives me

```YGR 0.5 INFLATION 6.1651 INT 9.1651```
but it still produces the same error as above when I try to run the estimation. Would someone mind letting me know what I’ve done wrong?

In the second code, you forgot to initialize all the parameters.

Thank you very much for the reply. I’ve tried initializing the parameters both as their prior mean values, and as the posterior mean values the original author derived and neither are working. Initially when I read your reply I thought it was kind of an odd suggestion, since the first code produces a solution using the prior mean values as initial values, which I understand is the default if you don’t specify separate initial values for the parameters.

I don’t suppose you have any more ideas? I’m about to do everything over again, but I find it incredibly strange that identical equations and initial values for the parameters would produce a solution in the first (simple irf) case, but not in the second (estimation) case. Furthermore, the first code will produce a solution even with initial variable values all 0, so I don’t think it can be an initial variable value problem.

I am not sure you understood my suggestion correctly. Of course, if you do not specify initial values in the estimated_params; block, Dynare takes the prior means as starting values for estimation. However, your code execution does not reach the estimation command. Rather it crashes in the steady command, the reason being that you did not initialize your parameters before the model block (which you did in the first model). Only if Dynare completed this command, it would use the prior means of the estimated_params-block for the estimation.
Hence, just copy the parameter initialization from the other code before the model-block (the values do not matter as they are overwritten by the prior means) or try omitting the steady and check commands so Dynare directly jumps to estimation.

Sorry for the late reply – thank you very much for your help.