Debian Codegraph @

tests/estimation/method_of_moments/RBC/RBC_MoM_steady_helper.m

raw
1 % =========================================================================
2 % Copyright © 2020-2022 Dynare Team
3 %
4 % This file is part of Dynare.
5 %
6 % Dynare is free software: you can redistribute it and/or modify
7 % it under the terms of the GNU General Public License as published by
8 % the Free Software Foundation, either version 3 of the License, or
9 % (at your option) any later version.
10 %
11 % Dynare is distributed in the hope that it will be useful,
12 % but WITHOUT ANY WARRANTY; without even the implied warranty of
13 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 % GNU General Public License for more details.
15 %
16 % You should have received a copy of the GNU General Public License
17 % along with Dynare. If not, see <https://www.gnu.org/licenses/>.
18 % =========================================================================
19 function [N, info]= RBC_MoM_steady_helper(THETA,ETAl,ETAc,BETTA,B,C_O_N,W)
20 info=0;
21 if ~isreal(C_O_N)
22 info=1;
23 N=NaN;
24 return;
25 end
26 if ETAc == 1 && ETAl == 1
27 N = (1-BETTA*B)*(C_O_N*(1-B))^-1*W/THETA/(1+(1-BETTA*B)*(C_O_N*(1-B))^-1*W/THETA);
28 else
29 % No closed-form solution use a fixed-point algorithm
30 N0 = 1/3;
31 try
32 [N, ~, exitflag] = fsolve(@(N) THETA*(1-N)^(-ETAl)*N^ETAc - (1-BETTA*B)*(C_O_N*(1-B))^(-ETAc)*W, N0,optimset('Display','off','TolX',1e-12,'TolFun',1e-12));
33 if exitflag<1
34 info=1;
35 end
36 catch
37 N=NaN;
38 info=1;
39 end
40 end