Initval vs Steady State

I used the Matlab equation solver (fsolve) to calculate the steady state. Took 8 iterations for it to reach the SS. I then feed these numbers into initval and my simple model run.

But, when I used steady_state_model and feed the block with the same value from fsolve, it gave me an error.

Does this mean that if I am using fsolve, I can only use initval but not steady_state_model?

You need to verify whether the solution you got with fsolve actually is a steady state of the model implemented in Dynare. use resid before steady to check the initvals.

1 Like

Yes. No residual.

What I am asking is; instead of taking the result from fsolve and put it into initval, can I take the result and put it into steady_state_model?

Yes, of course.

When I do that it gave me an error.

I would need to see the files.

Here you go. It runs if I use initval, it doesn’t run if I use steady_state_model.

var c n k z r w y;
predetermined_variables k;
varexo e_z;
parameters beta theta delta rho a;

beta = 0.99;
delta = 0.025;
theta = 0.36;
a = 1.72;
rho = 0.95;


params = [beta theta delta a];
init = [0.5 0.1 1 0.1 0.1 0.1];

options  = optimset('Display','iter');
[ss,Fval,exitflag] = fsolve('rbc_ss',init,options,params);


model;
w / c = a / (1 - n);
beta * ((1/c(+1)) * (r(+1) + 1 - delta)) = 1 / c;
c + k(+1) = w * n + r * k + (1 - delta) * k;
y = exp(z) * k^(theta) * n^(1 - theta);
w = (1 - theta) * exp(z) * k^(theta) * n^(-theta);
r = theta * exp(z) * k^(theta - 1) * n^(1 - theta);
z = rho*(z(-1)) + e_z;

end;

steady_state_model;
z = 0;
c = ss(1);
n = ss(2);
k = ss(3);
r = ss(4);
w = ss(5);
y = ss(6);
end;

model_diagnostics;
resid;
steady;

shocks;
var e_z = 0.01^2;
end;

stoch_simul(periods=2000, drop=200,irf = 100,order=3);

For the steady state calc;

function X = rbc_ss(initial,param)

beta = param(1);
theta = param(2);
delta = param(3);
a = param(4);

c = initial(1);
n = initial(2);
k = initial(3);
r = initial(4);
w = initial(5);
y = initial(6);

X = [
w / c - a / (1 - n);
beta * (1/c * (r + 1 - delta)) - 1 / c;
c + k - w * n - r * k - (1 - delta) * k;
y - k^(theta) * n^(1 - theta);
w - (1 - theta) * k^(theta) * n^(-theta);
r - theta * k^(theta - 1) * n^(1 - theta);
];

1 Like

Sorry, but I don’t see the point for even having this complexity here. You are solving for the steady state with brute force. Your file is equivalent to

var c n k z r w y;
predetermined_variables k;
varexo e_z;
parameters beta theta delta rho a;

beta = 0.99;
delta = 0.025;
theta = 0.36;
a = 1.72;
rho = 0.95;

model;
w / c = a / (1 - n);
beta * ((1/c(+1)) * (r(+1) + 1 - delta)) = 1 / c;
c + k(+1) = w * n + r * k + (1 - delta) * k;
y = exp(z) * k^(theta) * n^(1 - theta);
w = (1 - theta) * exp(z) * k^(theta) * n^(-theta);
r = theta * exp(z) * k^(theta - 1) * n^(1 - theta);
z = rho*(z(-1)) + e_z;

end;

initval;
z = 0;
c = 0.5;
n = 0.1;
k = 1;
r = 0.1;
w = 0.1;
y = 0.1;
end;

model_diagnostics;
resid;
steady;

shocks;
var e_z = 0.01^2;
end;

stoch_simul(periods=2000, drop=200,irf = 100,order=3);

Yes. I acknowledge that. Because I am learning how to use fsolve together with Dynare, in case I have a more complex model where I am not able to find the analytical steady states.

Does this mean that fsolve cannot be used with steady_state_model?

In that case, you should use a steady state file. The steady_state_model-block would mostly work for easier setups. See the example3.mod in Dynare’es examples-folder

Is there a way to use the value of the steady_state inside the model block?

Yes, use the steady_state()-operator.

Dear Johannes, is there a difference between “initval” and “steady_state_model”?

I have difficulty finding a unique steady state of a Ramsey model – it confirms any value of inflation I give it as steady state – even though the associated loss cleary varies with the rate of inflation.

I think this issue is indicated in Dynare manuel PDF document.

initval is an initial guess for steady state values of the model when we do not know exact values of steady states of the variables as I know.

Yes indeed, I solved the problem now. Thank you!

Yes. A conditional steady state file or steady_state_model-block should allow selecting on particular steady state.