Basic Model Not Running


#1

Hi,

I have a basic model with 8 unknowns and 8 equations. When I try to run it, the residual of the last static equation is -inf. And the equation is correct, hence I do not understand the problem. I would appreciate it if anyone could help with some suggestions.

Residuals of the static equations:

Equation number 1 : -0.9816 : G function for L firm
Equation number 2 : 0.15902 : Euler for L firm
Equation number 3 : 0.21444 : Sigma for L firm
Equation number 4 : 0.12644 : Profits for L firm
Equation number 5 : -0.64 : G function for H firm
Equation number 6 : 0.16462 : Euler for H firm
Equation number 7 : 0.75441 : Sigma for H firm
Equation number 8 : 0.1355 : Profits for H firm
Equation number 9 : 0 : Total output
Equation number 10 : -Inf : Inverse demand function

I am running this in Dynare using the code below:

clear; close all; clc

addpath /Applications/Dynare/4.5.6/
addpath /Applications/Dynare/4.5.6/matlab/

cd /Users/lauraft/Dropbox/Dynare
dynare Model

%------------------------------------------------------------
% Declare endogenous and exogenous variables
%------------------------------------------------------------
var kH kL P Y SigH SigL profitL profitH AL AH;

varexo mH;

%------------------------------------------------------------
% Declare model parameters
%------------------------------------------------------------

parameters Abar alpha beta gamma Pbar r rho maxT zL zH sigmaA2 sigmaE2 sigmaTheta2 sigmamH2;

%------------------------------------------------------------
% Calibrated parameters
%------------------------------------------------------------

Abar=3;
alpha=0.5;
beta=0.98;
gamma=1;

Pbar=1;
r=0.2;
rho=0.6;

maxT=8;
zL=1;
zH=2;

sigmamH2=0.01;

%------------------------------------------------------------
% Shocks parameters (mean & variances)
%------------------------------------------------------------
muE=0;
sigmaE2=2;%if 3, data savvy firm always above

muA=0;
sigmaA2=1;

muTheta=0.5;
sigmaTheta2=1;

% measure of data savvy firms

%------------------------------------------------------------
% Set DO_IRFS=1 to plot impulse responses
% Set DO_ESTIMATION=1 to do estimation
%------------------------------------------------------------
DO_IRFS = 1 ;

%------------------------------------------------------------
% Model equations
%------------------------------------------------------------

model ;

% Large size, bad data firms: LOW
%--------------------------------------
[name = ‘G function for L firm’]
AL = Abar - SigL- sigmaA2;

[name = ‘Euler for L firm’]
r * kL^(1-alpha)=alpha * P * AL + alpha * beta * zL * SigL(+1)^2 * sigmaE2 * P(+1) * kL(+1)^(alpha);

[name = ‘Sigma for L firm’]
SigL = ((rho^2*(SigL(-1)^(-1) + sigmaA2^(-1))^(-1) + sigmaTheta2)^(-1) + zL * kL(-1)^(alpha) * sigmaE2^(-1))^(-1);

[name = ‘Profits for L firm’]
profitL= Pbar * AL * kL^alpha - r * kL;

% Small size, good data firms: HIGH
%----------------------------------------
[name = ‘G function for H firm’]
AH = Abar - SigH - sigmaA2;

[name = ‘Euler for H firm’]
r * kH^(1-alpha)=alpha * P * AH + alpha * beta * zH * SigH(+1)^2 * sigmaE2 * P(+1) * kH(+1)^(alpha);

[name = ‘Sigma for H firm’]
SigH = ((rho^2*(SigH(-1)^(-1) + sigmaA2^(-1))^(-1) + sigmaTheta2)^(-1) + zH * kH(-1)^(alpha) * sigmaE2^(-1))^(-1);

[name = ‘Profits for H firm’]
profitH = Pbar * AH * kH^alpha -r * kH;

% Industry
%----------
[name = ‘Total output’]
Y= AL * kL^alpha + mH * AH* kH^alpha;

[name = ‘Inverse demand function’]
P = Pbar *Y^(-gamma);

end;

% STOCHASTIC PROCESSES FOR THE SHOCKS
%-------------------------------------

%------------------------------------------------------------
% Initial conditions
%------------------------------------------------------------

initval;
kL=0.6322;
kH=0.6775;
SigH=1.3600;
SigL=1.0184;
end;

%------------------------------------------------------------
% Declare shocks
%------------------------------------------------------------

shocks;
var mH=sigmamH2;

end;

%******************************************************************
%
% %%% %%% % % % %%% %
% % % % % % % % %
% %%% % % % % % %%% %
% % % % % % % %
% %%% %%% %%% % %%% %
%
%******************************************************************

%------------------------------------------------------------
% Call steady state
%------------------------------------------------------------
resid(1);

steady;

%------------------------------------------------------------
% TO SEE PROPERTIES OF MODEL
%------------------------------------------------------------

if DO_IRFS==1;

stoch_simul (order=2,irf=20) kH kL profitH profitL P Y;

end;


#2

In your initval-block you did not set Y so it is assumed to be 0. This is infeasible as it is raised to a negative power.


#3

Thank you so much for replying. Unfortunately, even if I set Y=1, I still get the error below. Is there anything else I have to initialize or is the model not running because the guesses are too far off from SS?

Residuals of the static equations:

Equation number 1 : 0
Equation number 2 : 0
Equation number 3 : 0
Equation number 4 : 0
Equation number 5 : -0.64
Equation number 6 : 0.85841
Equation number 7 : 1.1974
Equation number 8 : -0.18127
Equation number 9 : 3.6023e-07
Equation number 10 : 0

Error using print_info (line 83)
Impossible to find the steady state. Either the model doesn’t have a steady state, there are an
infinity of steady states, or the guess values are too far from the solution

Error in steady (line 104)
print_info(info,options_.noprint, options_);

Error in Model (line 213)
steady;

Error in dynare (line 235)
evalin(‘base’,fname) ;

Error in DoModel (line 7)
dynare Model.mod


#4

I can only give you the standard answer to look at the equation with the big residuals. They often contain errors or at least give an indication on how to improve the initial guess.


#5

I got it going. The shocks were misspecified.

Can you still please help me with the following: how to write shocks to mH as permanent? I have them as AR(1), but the moment I write the process for mH as a unit root, Dynare cannot handle it.

%------------------------------------------------------------

% Model with two types of firms

% Declare endogenous and exogenous variables

%------------------------------------------------------------

var kBad kSavvy SigL SigH ABad ASavvy profitL profitH P Y mH;

varexo e;

%------------------------------------------------------------

% Declare model parameters

%------------------------------------------------------------

parameters Abar Ahat alpha beta gamma Pbar r rho maxT sigmaA2 sigmaE2 sigmaTheta2 zL zH mHSS sigmae;

%------------------------------------------------------------

% CABadibrated parameters

%------------------------------------------------------------

Abar=3;

Ahat=5;

alpha=0.5;

beta=0.98;

gamma=1;

Pbar=1;

r=0.2;

rho=0.95;

maxT=20;

mHSS=0.6;

%------------------------------------------------------------

% Shocks parameters (mean & variances)

%------------------------------------------------------------

muE=0;

sigmaE2=2;%if 3, data savvy firm ABadways above

muA=0;

sigmaA2=1;

muTheta=0.5;

sigmaTheta2=1;

sigmae=0.30;

% measure of data savvy firms

%mH=0.60;

zL=1;

zH=2;

%------------------------------------------------------------

% Model equations

%------------------------------------------------------------

model ;

% Large size, bad data firms: LOW

%--------------------------------------

[name = ‘G function for L firm’]

ABad=Abar*(Ahat-SigL-sigmaA2);

[name = ‘Euler for L firm’]

r * kBad^(1-alpha)=alpha * P AbarABad+ alpha * beta * zL * SigL(+1)^2 * sigmaE2^(-1) * P(+1) * kBad(+1)^(alpha);

[name = ‘Sigma for L firm’]

SigL = ((rho^2*(SigL(-1)^(-1) + sigmaA2^(-1))^(-1) + sigmaTheta2)^(-1) + zL* kBad(-1)^(alpha) * sigmaE2^(-1))^(-1);

[name = ‘Profits for L firm’]

profitL= Pbar * AbarABad kBad^alpha - r * kBad;

% sMABadL size, good data firms: HIGH

%--------------------------------------

[name = ‘G function for L firm’]

ASavvy=Abar*(Ahat-SigH-sigmaA2);

[name = ‘Euler for L firm’]

r * kSavvy^(1-alpha)=alpha * P * Abar*ASavvy+ alpha * beta * zH * SigH(+1)^2 * sigmaE2^(-1) * P(+1) * kSavvy(+1)^(alpha);

[name = ‘Sigma for L firm’]

SigH = ((rho^2*(SigH(-1)^(-1) + sigmaA2^(-1))^(-1) + sigmaTheta2)^(-1) + zH* kSavvy(-1)^(alpha) * sigmaE2^(-1))^(-1);

[name = ‘Profits for L firm’]

profitH= Pbar * AbarASavvy kSavvy^alpha - r * kSavvy;

% Industry

%----------

[name = ‘Inverse demand function’]

P = (AbarABadkBad^alpha+mHAbarASavvy*kSavvy^alpha)^(-gamma);

[name = ‘Output’]

Y=(AbarABadkBad^alpha+mHAbarASavvy*kSavvy^alpha);

%[name = ‘Permanent entry shock’]

mH= rho*mH(-1)+e;

end;

% STOCHASTIC PROCESSES FOR THE SHOCKS

%-------------------------------------

%------------------------------------------------------------

% Initial conditions

%------------------------------------------------------------

initval;

kBad=0.2067;

SigL=0.3600;

ABad=1;

kSavvy=0.0267;

SigH=0.0600;

ASavvy=2;

e=0;

end;

%------------------------------------------------------------

% Declare shocks

%------------------------------------------------------------

shocks;

var e=sigmae;

end;

%******************************************************************

%

% %%% %%% % % % %%% %

% % % % % % % % %

% %%% % % % % % %%% %

% % % % % % % %

% %%% %%% %%% % %%% %

%

%******************************************************************

%------------------------------------------------------------

% Call steady state

%------------------------------------------------------------

steady;

%------------------------------------------------------------

% TO SEE PROPERTIES OF MODEL

%------------------------------------------------------------

stoch_simul (order=1,irf=20) ABad ASavvy kBad kSavvy profitL profitH P Y;


#6

That is a problem. With a unit root, i.e. rho=1 your model will have infinitely many steady state and therefore steady state finding will almost surely not work. In this case, you need to provide the steady state you want to select to Dynare.