I am trying to simulate a model with bank runs (think Gertler-Kiyotaki, 2013) so my question is: how do I tell dynare to start in one economy in which a bank is operating and then, following a shock, transition to a new economy in which the bank doesn’t exist anymore? That is, following a large shock (and bank run) many of the equations are no longer valid. I can attempt to clarify my question if this is unclear…
Just an idea:
Perhaps you define a new parameter, which stands in front of all equations, that hold for economy, say A.
Then if economy A is valid, the parameter has the value 1, and if the economy A is not valid anymore, then the parameter value has the value 0.
Then you can calculated the transiton with the initval and endval command of dynare, where you set in initval the paramter on 1 and in endval the paramter on 0.
So here’s the issue: a bank run occurs if the price is below some threshold, Q_t < Qbar_t, where Qbar_t is some time-varying threshold. In the original SS, this condition is violated so there is no bank run. Now, suppose there’s an unexpected shock so large that this condition holds. Using your suggestion, I would define a variable like Run = Qbar - Q, and then another variable RunInd = 1*(Run<0) (so it’s 1 as long as there is no run). I then multiply every bank equation by RunInd. Fine. I want it to be the case that once there is a run, all banks are wiped out forever so N (net worth), S (equity), A (liabilities) are all zero going forward forever. However, it will be the case that the price Q will eventually return to its original SS so in the long-run I think the Run variable I just defined will be negative, and hence RunInd=1. But doesn’t this mean that those bank equations will then return?
My suggestion was the following:
Define a variable “run”. Then use the initval and endval to do the following:
run = 1; %meaning your “bank equations” are valid
run = 0; %meaning your “bank equations” are not valid
Then dynare computes the transition from one steady state to the new steady state.
Or when you want to do it with a shock variabel. Define a var_exo Qbar_t, which switches its value between 1 and 0, by using an approximation of an indicator function.
An indicator function of the following form
Run = 1 if Q_t<Qbar_t
Run = 0 else
can be approximated by the following logistic function:
Run = 1/(1+exp(-10000(Qbar_t - Q_t))*
and Qbar_t then follows some specified exogenous process.
I hope this helps and I hope I understood your problem right.
Please clarify the exercise you are trying to do. Is it a stochastic or deterministic setup? In stochastic setup, the type of nonlinearity is very hard to deal with. If we are talking about a deterministic perfect foresight setup where everything is certain after the initial shock, you can really work with the initval-endval construct.
It’s deterministic in the sense that the run is completely unanticipated, so I understand now that the initval-endval construct should work. Below is a portion of the code (I realize everything below is in logs but I will get rid of those later).
exp(A) = exp(N) + exp(D) - exp(Q)*exp(S);
exp(lam) = exp(mu)/(theta*(1 - exp(om)) - exp(mu));
exp(N) = (sig + xi)*((exp(Z)+(1-del)*exp(Q))*exp(S(-1)) + exp(Ra(-1))*exp(A(-1))) - sig*exp(R(-1))*exp(D(-1));
exp(Om) = 1 - sig + sig*(exp(Va)*(1 + exp(lam)) - theta*exp(om)*exp(lam));
exp(lam) = (exp(Va) - exp(V))*(1 + exp(lam))/(theta*exp(om));
exp(Q)*exp(S) = ((theta*exp(om)+exp(V)-exp(Va))*exp(D)+(theta*exp(om)-exp(Va))*exp(N))/(exp(mu)-theta*(1-exp(om)));
exp(mu) = exp(SDF(+1))*exp(Om(+1))*(exp(Rs(+1)) - exp(Ra));
exp(Va) = exp(SDF(+1))*exp(Om(+1))*exp(Ra);
exp(V) = exp(SDF(+1))*exp(Om(+1))*exp(R);
exp(Lev) = (exp(Q(-1))*exp(S(-1))*exp(Rs)+exp(Ra(-1))*exp(A(-1)))/(exp(Q(-1))*exp(S(-1))*exp(Rs)+exp(Ra(-1))*exp(A(-1))-exp(R(-1))*exp(D(-1)));
exp(Aprime) = exp(Q)*exp(Sprime) - exp(Nprime);
exp(lamprime) = exp(muprime)/(exp(phi) - exp(muprime));
exp(Nprime) = (sig + xiprime)*(exp(Z)+(1-del)*exp(Q))*exp(Sprime(-1)) - sig*exp(Ra(-1))*exp(Aprime(-1));
exp(Omprime) = 1 - sig + sig*(1 + exp(lamprime))*exp(Vaprime);
exp(muprime) = exp(phi) - (exp(Vaprime)*exp(Nprime))/(exp(Q)*exp(Sprime));
exp(muprime) = exp(SDF(+1))*exp(Omprime(+1))*(exp(Rs(+1)) - exp(Ra));
exp(Vaprime) = exp(SDF(+1))*exp(Omprime(+1))*exp(Ra);
exp(Levprime) = (exp(Q(-1))*exp(Sprime(-1))*exp(Rs))/(exp(Q(-1))*exp(Sprime(-1))*exp(Rs)-exp(Ra(-1))*exp(Aprime(-1)));
exp(K) = exp(S) + exp(Sprime);
exp(A) = exp(Aprime);
In the original SS (before the run), all of these equations hold. To understand what I’m doing, everything in the EQUATIONS 1 block denotes equations for bank 1, anything in EQUATIONS 2 is for bank 2, and the final block is market clearing. Also, S, A, N, D are bank 1 balance sheet terms and Sprime, Aprime, Nprime are bank 2 balance sheet terms. Pre-run, both banks exist so all of these terms are nonzero. Post-run, bank 2 disappears so Sprime = Aprime = Nprime = 0. A run will occur under conditions I specified in a previous post.