# The Jacobian matrix evaluated at the steady state contains elements that are not real or are infinite

I am writing a simple 2 model economies and I got this error, I am not sure where the mistake is? Is it my initial value or is there something wrong with my FOCs?

The BKK.pdf (41.7 KB) attached is the model derivation on paper;

``````var c cstar n nstar k kstar b bstar x xstar z zstar;
predetermined_variables k b;
varexo e estar;
parameters beta theta delta rho sigma a;

beta = 0.99;
delta = 0.025;
theta = 0.36;
a = 1;
rho = 0.98;
sigma   = .00852;

model;
/*
First Order Conditions for Home Economy
*/
c + x + beta*(c/c(+1)) * b(+1) = (1-theta) * z * k^theta * n^(-theta) + theta * z * k^(theta - 1) * n^(1 - theta)*k(-1)+b;
k = (1-delta)*k(-1) + x;
1/c = beta * (1/c(+1)) * theta * z(+1) * k(+1)^(theta - 1) * n(+1)^(1 - theta)*k(-1) + (1-delta);
a/(1-n) = ((1-theta) * z * k^theta * n^(-theta))/c;
z = rho * z(-1) + e;

/*
First Order Condition of Foreign Country
*/
cstar + xstar + beta*(c/cstar(+1)) * bstar(+1) = (1-theta) * zstar * kstar^theta * nstar^(-theta) + theta * zstar * kstar^(theta - 1) * nstar^(1 - theta)*kstar(-1)+bstar;
kstar = (1-delta)*kstar(-1) + xstar;
1/cstar = beta * (1/cstar(+1)) * theta * zstar(+1) * kstar(+1)^(theta - 1) * nstar(+1)^(1 - theta)*kstar(-1) + (1-delta);
a/(1-nstar) = ((1-theta) * zstar * kstar^theta * nstar^(-theta))/cstar;
zstar = rho * zstar(-1) + estar;

/*
Resource Constraint
*/
z * k^(theta) * n^(1-theta) = c + x;
zstar * kstar^(theta) * nstar^(1-theta) = cstar + xstar;
end;

initval;
k = 10.368;
c = 0.811177;
n = 0.332289;
z = 0;
e = 0;
b = 0;
x = 0;
kstar = 10.368;
cstar = 0.811177;
nstar = 0.332289;
zstar = 0;
estar = 0;
bstar = 0;
xstar = 0;
end;

shocks;
var e = sigma^2;
var estar = sigma^2;
corr e, estar = 0.258;
end;

stoch_simul(hp_filter = 1600, order = 1, periods=125);[BKK.pdf|attachment](upload://p0SK0wjtvYs7gTedokVCNAQikMA.pdf) (41.7 KB)``````

You have

``````z = rho * z(-1) + e;
``````

which implies `z` (and `zstar`) has steady state 0. But then in the production function you are missing an `exp()`

Hi Professor,

Thanks for catching that up.

Now, that I changed this, it seems that my model is now throwing out Blanchard Kahn condition not satisfied.

I am not sure which of the variable has a wrong timing; both bond and capital are declared as predetermined variables.

Or am I wrong because I didn’t include any bond clearing condition?

Thank you.

``````var c cstar n nstar k kstar b bstar x xstar z zstar;
predetermined_variables k kstar b bstar;
varexo e estar;
parameters beta theta delta rho sigma a;

beta = 0.99;
delta = 0.025;
theta = 0.36;
a = 1;
rho = 0.98;
sigma   = .00852;

model;
/*
First Order Conditions for Home Economy
*/
c + x + beta*(c/c(+1)) * b(+1) = (1-theta) * exp(z) * k^theta * n^(-theta) + theta * exp(z) * k^(theta - 1) * n^(1 - theta)*k(-1)+b;
k = (1-delta)*k(-1) + x;
1/c = beta * (1/c(+1)) * theta * exp(z(+1)) * k(+1)^(theta - 1) * n(+1)^(1 - theta)*k(-1) + (1-delta);
a/(1-n) = ((1-theta) * exp(z) * k^theta * n^(-theta))/c;
z = rho * z(-1) + e;

/*
First Order Condition of Foreign Country
*/
cstar + xstar + beta*(c/cstar(+1)) * bstar(+1) = (1-theta) * exp(zstar) * kstar^theta * nstar^(-theta) + theta * exp(zstar) * kstar^(theta - 1) * nstar^(1 - theta)*kstar(-1)+bstar;
kstar = (1-delta)*kstar(-1) + xstar;
1/cstar = beta * (1/cstar(+1)) * theta * exp(zstar(+1)) * kstar(+1)^(theta - 1) * nstar(+1)^(1 - theta)*kstar(-1) + (1-delta);
a/(1-nstar) = ((1-theta) * exp(zstar) * kstar^theta * nstar^(-theta))/cstar;
zstar = rho * zstar(-1) + estar;

/*
Resource Constraint
*/
exp(z) * k^(theta) * n^(1-theta) = c + x;
exp(zstar) * kstar^(theta) * nstar^(1-theta) = cstar + xstar;
end;

initval;
k = 2.60696;
c = 0.733643;
n = 0.410675;
z = 0;
e = 0;
b = -73.3643;
x = 0.0651741;
kstar = 2.60696;
cstar = 0.733643;
nstar = 0.410675;
zstar = 0;
estar = 0;
bstar = -73.3643;
xstar = 0.0651741;
end;

shocks;
var e = sigma^2;
var estar = sigma^2;
corr e, estar = 0.258;
end;

stoch_simul(hp_filter = 1600, order = 1, periods=125);``````

Are you sure about the timing, e.g.

``````1/c = beta * (1/c(+1)) * theta * exp(z(+1)) * k(+1)^(theta - 1) * n(+1)^(1 - theta)*k(-1) + (1-delta);
``````

why is there k(+1) and k(-1)?

I didn’t even notice that.

I have made changes to the model; I fixed the mistake you pointed to, I fixed the mistake in the budget constraint (n was not multiplied to the wage equation) and I put a bond clearing equation and goods market clearing condition.

I managed to get the steady state for each variable. But I was still unable to do a stochastic simulation.

Blanchard Kahn conditions not satisfied.

``````var c cstar n nstar k kstar b bstar x xstar z zstar;
predetermined_variables k kstar b bstar;
varexo e estar;
parameters beta theta delta rho sigma a;

beta = 0.99;
delta = 0.025;
theta = 0.36;
a = 1;
rho = 0.98;
sigma   = .00852;

model;
/*
First Order Conditions for Home Economy
*/
c + x + beta*(c/c(+1)) * b(+1) = (1-theta) * exp(z) * k^theta * n^(-theta) * n + theta * exp(z) * k^(theta - 1) * n^(1 - theta)*k(-1)+b;
k = (1-delta)*k(-1) + x;
1/c = beta * (1/c(+1)) * (theta * exp(z(+1)) * k(+1)^(theta - 1) * n(+1)^(1 - theta) + (1-delta));
a/(1-n) = ((1-theta) * exp(z) * k^theta * n^(-theta))/c;
z = rho * z(-1) + e;

/*
First Order Condition of Foreign Country
*/
cstar + xstar + beta*(c/cstar(+1)) * bstar(+1) = (1-theta) * exp(zstar) * kstar^theta * nstar^(-theta) * nstar + theta * exp(zstar) * kstar^(theta - 1) * nstar^(1 - theta) * kstar(-1) + bstar;
kstar = (1-delta)*kstar(-1) + xstar;
1/cstar = beta * (1/cstar(+1)) * (theta * exp(zstar(+1)) * kstar(+1)^(theta - 1) * nstar(+1)^(1 - theta) + (1-delta));
a/(1-nstar) = ((1-theta) * exp(zstar) * kstar^theta * nstar^(-theta))/cstar;
zstar = rho * zstar(-1) + estar;

/*
Resource Constraint
*/
exp(z) * k^(theta) * n^(1-theta) + exp(zstar) * kstar^(theta) * nstar^(1-theta) = c + x + cstar + xstar;
b + bstar = 0;
end;

initval;
k = 2.60696;
c = 0.733643;
n = 0.410675;
z = 0;
e = 0;
b = -73.3643;
x = 0.0651741;
kstar = 2.60696;
cstar = 0.733643;
nstar = 0.410675;
zstar = 0;
estar = 0;
bstar = -73.3643;
xstar = 0.0651741;
end;

There are still `k(-1)` showing up that should not be there. Please check all equations.

I changed the timing of the capital stock;

I couldn’t find the steady state with this setup.

BKKnew.pdf (49.2 KB)

``````var c cstar n nstar k kstar b bstar z zstar r rstar w wstar q;
predetermined_variables k kstar b bstar;
varexo e estar;
parameters beta theta delta rho sigma a;

beta = 0.99;
delta = 0.025;
theta = 0.36;
a = 1;
rho = 0.98;
sigma   = .00852;

model;
/*
First Order Conditions for Home Economy
*/
c + k(+1) + q * b = w * n + r * k + (1 - delta) * k + b(-1);
1/c = beta * (1/c(+1)) * (r(+1) + 1 - delta);
a/(1-n) = -w/c;
q/c = beta * (1/c(+1));
z = rho * z(-1) + 0.08 * zstar(-1) + e;
r = theta * exp(z) * k^(theta - 1) * n^(1-theta);
w = (1 - theta) * exp(z) * k^(theta) * n^(-theta);

/*
First Order Condition of Foreign Country
*/
cstar + kstar(+1) + q * bstar = wstar * nstar + rstar * kstar + (1 - delta) * kstar + bstar(-1);
1/cstar = beta * (1/cstar(+1)) * (rstar(+1) + 1-delta);
a/(1-nstar) = -wstar/cstar;
q/cstar = beta * (1/cstar(+1));
zstar = rho * zstar(-1) + 0.08*z(-1) + estar;
rstar = theta * exp(zstar) * kstar^(theta - 1) * nstar^(1-theta);
wstar = (1 - theta) * exp(zstar) * kstar^(theta) * nstar^(-theta);

/*
Resource Constraint
*/
b + bstar = 0;
end;``````

A change in timing does not affect the steady state. So what else did you change?

Hey Professor.

I just realized that this problem is indeterminate(?), because if you look at the price of bond, it is completely exogenous, it is equal to beta.

To solve this problem, I have to put some restrictions either through a portfolio adj cost, debt limit or collateral constraints.

In my new code there is a new debt limit; bond divided by output has to be larger than a number (in this case it is 1, or 100% debt to GDP limit).

I am still unable to find the SS, the residual is around 0.05.

Is there a better way to debug this? Because right now, I don’t even know which one of my equation is wrong. I have derived everything on paper.

``````var c cstar n nstar k kstar b bstar z zstar r rstar w wstar q lambda lambdastar mu mustar y ystar;
predetermined_variables k kstar b bstar;
varexo e estar;
parameters beta theta delta rho rhostar sigma a debtlimit;

beta = 0.99;
delta = 0.025;
theta = 0.36;
a = 1;
rho = 0.906;
rhostar = 0.088;
sigma   = .00852;
debtlimit = 1;

model;
/*
First Order Conditions for Home Economy
*/
y = exp(z) * k^theta * n^(1 - theta);

c + k(+1) + q * b = w * n + r * k + (1 - delta) * k + b(-1);
b/y = - debtlimit;

1/c = lambda;
-a/(1-n) = lambda * w + mu * ((b * w)/(y^2));
lambda = beta * ((lambda(+1) * (r(+1) + 1 - delta)) + (mu(+1) * (b(+1) * r(+1))/(y(+1)^2)));
beta * lambda(+1) = lambda * q + mu * (1/y);

z = rho * z(-1) + rhostar * zstar(-1) + e;
r = theta * exp(z) * k^(theta - 1) * n^(1-theta);
w = (1 - theta) * exp(z) * k^(theta) * n^(-theta);

/*
First Order Condition of Foreign Country
*/
ystar = exp(zstar) * kstar^theta * nstar^(1 - theta);

cstar + kstar(+1) + q * bstar = wstar * nstar + rstar * kstar + (1 - delta) * kstar + bstar(-1);
bstar/ystar = - debtlimit;

1/cstar = lambdastar;
-a/(1-nstar) = lambdastar * wstar + mustar * ((bstar * wstar)/(ystar^2));
lambdastar = beta * ((lambdastar(+1) * (rstar(+1) + 1 - delta)) + (mustar(+1) * (bstar(+1) * rstar(+1))/(ystar(+1)^2)));
beta * lambdastar(+1) = lambdastar * q + mustar * (1/ystar);

zstar = rho * zstar(-1) + rhostar * z(-1) + estar;
rstar = theta * exp(zstar) * kstar^(theta - 1) * nstar^(1-theta);
wstar = (1 - theta) * exp(zstar) * kstar^(theta) * nstar^(-theta);

/*
Resource Constraint
*/
b + bstar = 0;
end;

initval;
k = 1;
c = 1;
n = 0.5;
z = 0;
e = 0;
b = -0.5;
y = 1;
lambda = 1;
mu = 1;
w = 1;
r = 1;

kstar = 1;
cstar = 1;
nstar = 0.5;
zstar = 0;
estar = 0;
bstar = 0.5;
ystar = 1;
lambdastar = 1;
mustar = 1;
wstar = 1;
rstar = 1;
q = 0.1;
end;
resid;
check;``````

I am not sure I understand. If your model does not feature a unique steady state due to a unit root, you should still be able to compute the steady state.

Do you have any suggestion on how to approach this problem?

As suggested by the Documentation (make a small model before attempting a bigger one), I did the same model, but I removed the bonds, and I managed to calculate a steady state and I managed to do some simulation as well.

Then, I put the bonds back in, and the model is unable to find a steady state and I am at a lost as to where and why this is the case.

If you got the steady state without bonds, computing it with them should be straightforward. It’s just one more variable.

Bonds, especially long-term bonds, are tricky in this case: the prices are functions instead of steady-state deviations.
If you have a short-term bond, i.e., the bond would be paid back every period and then you re-issue some new bond, then what Johannes said is correct.
If you have a long-term bond, you need another equation to govern the price of the bond. An example would be what “Sticky Leverage” (AER) did, and you can check that.

I implemented the model with one period bond.

• The household pays q in this period and gets 1 unit of consumption in the next period.
• There is a borrowing constraint; i.e. the bond purchase must not exceed a debt limit (100% of output)

Now, when I inserted bonds into the equation, the model is unable to compute steady state when I used model_diagnostics.

So, I think there are a few reasons why this could be so;

• The model is closed by this equation b(+1) + bstar(+1) = 0. Which means that net supply of bond is 0. Not sure if it should be (+1) or not.

• The bond price is universal. So, q appears in both the budget constraints for the two countries. In equilibrium, q is the same in both countries, so that the bond market clears.

• There is now a mu for both countries; mu and mustar. Mu is the lagrange multiplier in from of the debt limit constraint.

So, since the model with just capital runs perfectly (I can compute SS and run sim), and the model with the bond can’t, where could the problem lie?

``````var c cstar n nstar k kstar z zstar r rstar w wstar y ystar b bstar mu mustar q;
predetermined_variables k kstar b bstar;
varexo e estar;
parameters beta theta delta rho rhostar sigma a debtlimit;

beta = 0.99;
delta = 0.025;
theta = 0.36;
a = 1;
rho = 0.906;
rhostar = 0.088;
sigma   = .00852;
debtlimit = 1;

model;
/*
Home Economy
*/
y = exp(z) * k^theta * n^(1 - theta);

c + k(+1) + q * b(+1) = w * n + r * k + (1 - delta) * k + b;
b(+1) = - debtlimit * y;

a/(1-n) = (1/c) * w;
(1/c) = beta * ((1/c(+1)) * (r(+1) + 1 - delta));
beta * (1/c(+1)) = q * (1/c) + mu;

z = rho * z(-1) + rhostar * zstar(-1) + e;
r = theta * exp(z) * k^(theta - 1) * n^(1-theta);
w = (1 - theta) * exp(z) * k^(theta) * n^(-theta);

/*
Foreign Economy
*/
ystar = exp(zstar) * kstar^theta * nstar^(1 - theta);

cstar + kstar(+1) + q * bstar(+1) = wstar * nstar + rstar * kstar + (1 - delta) * kstar + bstar;
bstar(+1) = - debtlimit * ystar;

a/(1-nstar) = (1/cstar) * wstar;
(1/cstar) = beta * ((1/cstar(+1)) * (rstar(+1) + 1 - delta));
beta * (1/cstar(+1)) = q * (1/cstar) + mustar;

zstar = rho * zstar(-1) + rhostar * z(-1) + estar;
rstar = theta * exp(zstar) * kstar^(theta - 1) * nstar^(1-theta);
wstar = (1 - theta) * exp(zstar) * kstar^(theta) * nstar^(-theta);

b(+1) + bstar(+1) = 0;
end;

initval;
k = 17.5724;
c = 1.27405;
n = 0.462562;
z = 0;
e = 0;
y = 1.71336;
w = 2.3706;
r = 0.035101;
b = 0;
mu = 0;

kstar = 17.5724;
cstar = 1.27405;
nstar = 0.462562;
zstar = 0;
estar = 0;
ystar = 1.71336;
wstar = 2.3706;
rstar = 0.035101;
bstar = 0;
mustar = 0;

q = 0;

end;
//resid;
model_diagnostics;``````

Again, why do you not compute the steady state analytically?

When you say analytical; do you mean, instead of writing initval in specific values, I just write it in terms of SS equations?

I have entered the analytical steady state in the steady state block.

There is only one residual, the last equation. I suspect something is wrong with my bond market clearing equation.

``````var c cstar n nstar k kstar z zstar r rstar w wstar y ystar b bstar mu mustar q;
predetermined_variables k kstar b bstar;
varexo e estar;
parameters beta theta delta rho rhostar sigma a debtlimit;

beta = 0.99;
delta = 0.025;
theta = 0.36;
a = 1;
rho = 0.906;
rhostar = 0.088;
sigma   = .00852;
debtlimit = 1;

model;
/*
Home Economy
*/
y = exp(z) * k^theta * n^(1 - theta);

c + k(+1) + q * b(+1) = w * n + r * k + (1 - delta) * k + b;
b(+1) = - debtlimit * y;

a/(1-n) = (1/c) * w;
(1/c) = beta * ((1/c(+1)) * (r(+1) + 1 - delta));
beta * (1/c(+1)) = q * (1/c) + mu;

z = rho * z(-1) + rhostar * zstar(-1) + e;
r = theta * exp(z) * k^(theta - 1) * n^(1-theta);
w = (1 - theta) * exp(z) * k^(theta) * n^(-theta);

/*
Foreign Economy
*/
ystar = exp(zstar) * kstar^theta * nstar^(1 - theta);

cstar + kstar(+1) + q * bstar(+1) = wstar * nstar + rstar * kstar + (1 - delta) * kstar + bstar;
bstar(+1) = - debtlimit * ystar;

a/(1-nstar) = (1/cstar) * wstar;
(1/cstar) = beta * ((1/cstar(+1)) * (rstar(+1) + 1 - delta));
beta * (1/cstar(+1)) = q * (1/cstar) + mustar;

zstar = rho * zstar(-1) + rhostar * z(-1) + estar;
rstar = theta * exp(zstar) * kstar^(theta - 1) * nstar^(1-theta);
wstar = (1 - theta) * exp(zstar) * kstar^(theta) * nstar^(-theta);

b(+1) + bstar(+1) = 0;

//y + ystar = c + cstar + k(+1) - (1-delta)*k + kstar(+1) - (1-delta)*kstar;
end;

r = (1/beta) + delta - 1;
n = 1 / (1 + (a/(1-theta)) * (1 - delta * theta * (beta/(1 + beta * delta - beta))));
k = (r / (theta * n^(1 - theta)))^(1/(theta-1));
y = k^theta * n^(1 - theta);
w = (1 - theta) * (y / n);
b = -debtlimit * y;
c = y - delta * k;
q = (w * n + r * k - delta * k + b  - c) / b;
mu = (beta/c) - (q/c);

rstar = (1/beta) + delta - 1;
nstar = 1 / (1 + (a/(1-theta)) * (1 - delta * theta * (beta/(1 + beta * delta - beta))));
kstar = (rstar / (theta * nstar^(1 - theta)))^(1/(theta-1));
ystar = kstar^theta * nstar^(1 - theta);
wstar = (1 - theta) * (ystar / nstar);
bstar = -debtlimit * ystar;
cstar = ystar - delta * kstar;
mustar = (beta/cstar) - (q/cstar);

z = 0;
zstar = 0;
end;

model_diagnostics;
resid;
Change your last equation to `b(+1) = bstar(+1)`. You are welcome.