by ogol77 » Thu Feb 04, 2016 1:07 pm
Dear Johannes,
thank you very much for your kind and speedy reply!
Please, see below the code. What I am trying to do is to run through a parameter space and see if the model converges to the steady state (at any combination of the parameters). My problem is that I do not know how to force dynare to continue iteration and not to break the loop UNTIL it finds the combination of parameters which gives the steady state.
You are right, it makes sense to solve for the ss analytically first - but then I will still need to find the right parameters, very probably.
Would you be so kind to take a look at the code and may be you have some idea how to force the loop not to break until... The thing is I do not know how to state the condition for break - e.g. what is the value (in output?) that means that steady state has been found?
Can not thank you enough!
The code:
//1. Variable declaration
//------------------------------------------------------------------------------------------------------------------------
var pr, ri, rl, rd, d, dstar, pai, paistar, n, nstar, ne, nestar, dt, nt, net, a, m, lnpr, lnri, lnrl, lnrd, lnd, lnnn, lnne, lndstar, lnnstar, lnnestar, lndt, lnnt, lnnet;
//8 variables + 2 shocks
varexo ua um;
//------------------------------------------------------------------------------------------------------------------------
// 2. Parameter declaration and calibration
//------------------------------------------------------------------------------------------------------------------------
parameters beta, alpha, phi, gama, csi, pho, kai, mu, roa, rhom;
pho_vec=0.1:0.05:0.25;
mu_vec=0.05:0.05:0.15;
beta_vec=0.85:0.005:0.9;
for p=1:length(pho_vec)
for q=1:length(mu_vec)
for i=1:length(beta_vec)
alpha=0.7;
phi=2;
gama=3;
csi=0.2;
gama=3;
csi=0.2;
roa=0.95;
rhom = 0.9;
kai=2.1;
pho=pho_vec(p);
mu=mu_vec(q);
beta=beta_vec(i);
//-----------------------------------------------------------------------------------------------------------------------
// 3. The model
//-----------------------------------------------------------------------------------------------------------------------
model;
a = roa*a(-1)+ua;
m = rhom*m(-1)+um;
pr = exp(a) - alpha*exp(a)*ri;
rl = exp(a)/alpha - phi*dt;
rd = gama*dt;
ri = 1/alpha- ((phi/2*exp(a))*dt);
dt * (exp(a)/alpha - (phi+gama)*dt - csi) = - (exp(a)/alpha - 2*(phi+gama)*dt - csi)*d; //individual deposits from banks' F.O.C.
dt * (exp(a)/alpha - (phi+gama)*dt - csi - mu*exp(m)) = - (exp(a)/alpha - 2*(phi+gama)*dt - csi - mu*exp(m))*dstar; //individual deposits from banks' F.O.C.
pai = pr*((1+rl)-(1+rd)-csi)*d;
paistar = pr*((1+rl)-(1+rd)-csi-mu*exp(m))*dstar;
pai = kai*(1-beta*(1-pho));
paistar = kai*(1-beta*(1-pho));
n(+1) = (1-pho)*(n+ne);
nstar(+1) = (1-pho)*(nstar+nestar);
dt = ((n/(1-pho))*d+(nstar/(1-pho))*dstar);
nt = n + nstar;
net = ne + nestar;
lnpr = ln(pr);
lnri = ln(ri);
lnrl = ln(rl);
lnrd = ln(rd);
lnd = ln(d);
lnnn = ln(n);
lnne = ln(ne);
lndstar = ln(dstar);
lnnstar = ln(nstar);
lnnestar = ln(nestar);
lndt = ln(dt);
lnnt = ln(nt);
lnnet = ln(net);
end;
//--------------------------------------------------------------------------------------------------------------------------
// 4. Steady state
//--------------------------------------------------------------------------------------------------------------------------
initval;
pr = 0.0530488;
ri = 1.72173;
rl = 1.62528;
rd = 0.289357;
d = 5.75273;
dstar = 5.93008;
pai = 0.255102;
paistar = 0.255102;
n = 0.0171855;
nstar = 0.0166716;
ne = 0.000440655;
nestar = 0.000427476;
dt = 2.5;
nt = 0.02;
net = 0.0008;
a = 0;
lnpr = ln(pr);
lnri = ln(ri);
lnrl = ln(rl);
lnrd = ln(rd);
lnd = ln(d);
lnnn = ln(n);
lnne = ln(ne);
lndstar = ln(dstar);
lnnstar = ln(nstar);
lnnestar = ln(nestar);
lndt = ln(dt);
lnnt = ln(nt);
lnnet = ln(net);
end;
resid(1);
steady;
//---------------------------------------------------------------------------------------------------------------------------
// 5. shocks
//---------------------------------------------------------------------------------------------------------------------------
shocks;
var ua; stderr 0.01;
//var um; stderr 0.01;
end;
stoch_simul (irf=30,order=1);
end
end
end