Debian Codegraph @

tests/bgp/fs2000/fs2000.mod

raw
1 /*
2 * This file is a modified version of 'fs2000.mod'.
3 *
4 * The difference is that, here, the equations are written in non-stationary form, and we test if
5 * we are able to identify the trends.
6 *
7 */
8
9 /*
10 * Copyright © 2019-2023 Dynare Team
11 *
12 * This file is part of Dynare.
13 *
14 * Dynare is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * Dynare is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with Dynare. If not, see <https://www.gnu.org/licenses/>.
26 */
27
28 var gM M;
29 var gA A k c y;
30 var P; // follows M(-1)/A
31 var W l d; // follows M(-1)
32 var R n;
33
34 varexo e_a e_m;
35
36 parameters alp bet gam mst rho psi del;
37
38 alp = 0.33;
39 bet = 0.99;
40 gam = 0.003;
41 mst = 1.011;
42 rho = 0.7;
43 psi = 0.787;
44 del = 0.02;
45
46 model;
47 A = gA*A(-1);
48 M = gM*M(-1);
49 gA = exp(gam+e_a);
50 log(gM) = (1-rho)*log(mst) + rho*log(gM(-1))+e_m;
51 c+k = k(-1)^alp*(A*n)^(1-alp)+(1-del)*k(-1);
52 P*c = M;
53 P/(c(+1)*P(+1))=bet*P(+1)*(alp*k^(alp-1)*(A(+1)*n(+1))^(1-alp)+(1-del))/(c(+2)*P(+2));
54 (psi/(1-psi))*(c*P/(1-n))=W;
55 R = P*(1-alp)*k(-1)^alp*A^(1-alp)*n^(-alp)/W;
56 W = l/n;
57 M-M(-1)+d = l;
58 1/(c*P)=bet*R/(c(+1)*P(+1));
59 y = k(-1)^alp*(A*n)^(1-alp);
60 end;
61
62 verbatim;
63
64 bgp.write(M_);
65 y = 1+(rand(M_.endo_nbr,1)-.5)*.25;
66 g = ones(M_.endo_nbr,1);% 1+(rand(M_.endo_nbr,1)-.5)*.1;
67 if isoctave
68 options = optimset('Display','iter','Algorithm','levenberg-marquardt','MaxFunEvals',1000000,'MaxIter',100000,'GradObj','on','TolFun',1e-6,'TolX',1e-6);
69 else
70 options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-6,'StepTolerance',1e-6);
71 end
72 [y, fval, exitflag] = fsolve(@fs2000.bgpfun, [y;g], options);
73 if exitflag<1
74 error('Solution not found')
75 end
76 y(1:M_.orig_endo_nbr)
77 y(M_.endo_nbr+(1:M_.orig_endo_nbr))
78
79 end;