can solve model without var_obs, but not with

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

can solve model without var_obs, but not with

Postby jefflovejapan » Mon Sep 13, 2010 1:30 am

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: Select all
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-beta*h))*(1+beta*h^2) - h*y(-1) - beta*h*y(+1) +
    (1/1-beta*h)*d - (beta*h/1-beta*h)*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 = beta*pi(+1) + ((1-beta*omega)*(1-omega)/omega)*(d + eta*(y-a) - u + y - a)
     + ((1-omega)/omega)*(z - beta*omega*z(+1));

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

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

// equation 18 (Taylor rule)
r = rho_r*r(-1) + (1-rho_r)*(phi_pi*pi + phi_y*(y-yf)) + eps_r;

// equations 19-21
d = rho_d*d(-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;

steady;
check;


This gives me steady state values of:
Code: Select all
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:
Image
Where s, the vector of model variables is:
Image

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: Select all
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-beta*h))*(1+beta*h^2) - h*y(-1) - beta*h*y(+1) +
    (1/1-beta*h)*d - (beta*h/1-beta*h)*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 = beta*pi(+1) + ((1-beta*omega)*(1-omega)/omega)*(d + eta*(y-a) - u + y - a)
     + ((1-omega)/omega)*(z - beta*omega*z(+1));

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

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

// equation 18 (Taylor rule)
r = rho_r*r(-1) + (1-rho_r)*(phi_pi*pi + phi_y*(y-yf)) + eps_r;

// equations 19-21
d = rho_d*d(-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 + 4*pi;
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;

steady;
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);


only now I'm told that Dynare can't calculate the steady state.
Code: Select all
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
    [oo_.steady_state,check] = dynare_solve([M_.fname '_static'],...

Error in ==> steady at 52
steady_;

Error in ==> hirose at 152
steady;

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


I've tried entering the observables as regular variables to get steady state values in the simple code, which gives me
Code: Select all
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?
jefflovejapan
 
Posts: 13
Joined: Sat Aug 21, 2010 5:47 am

Re: can solve model without var_obs, but not with

Postby jpfeifer » Mon Sep 13, 2010 9:27 am

In the second code, you forgot to initialize all the parameters.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

thank you for the reply, but no success

Postby jefflovejapan » Tue Sep 21, 2010 1:42 pm

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.
jefflovejapan
 
Posts: 13
Joined: Sat Aug 21, 2010 5:47 am

Re: can solve model without var_obs, but not with

Postby jpfeifer » Tue Sep 21, 2010 4:44 pm

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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

thanks a lot

Postby jefflovejapan » Thu Oct 21, 2010 12:14 pm

Sorry for the late reply -- thank you very much for your help.
jefflovejapan
 
Posts: 13
Joined: Sat Aug 21, 2010 5:47 am


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 6 guests