| 1 |
% this is the exact model Qu and Tkachenk (2012, Quantitative Economics) |
| 2 |
% used in their replication file. |
| 3 |
% This file is used to check whether the G matrix is computed correctly. |
| 4 |
% Created by Willi Mutschler (@wmutschl, [email protected]) |
| 5 |
% ========================================================================= |
| 6 |
% Copyright © 2019-2020 Dynare Team |
| 7 |
% |
| 8 |
% This file is part of Dynare. |
| 9 |
% |
| 10 |
% Dynare is free software: you can redistribute it and/or modify |
| 11 |
% it under the terms of the GNU General Public License as published by |
| 12 |
% the Free Software Foundation, either version 3 of the License, or |
| 13 |
% (at your option) any later version. |
| 14 |
% |
| 15 |
% Dynare is distributed in the hope that it will be useful, |
| 16 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
% GNU General Public License for more details. |
| 19 |
% |
| 20 |
% You should have received a copy of the GNU General Public License |
| 21 |
% along with Dynare. If not, see <https://www.gnu.org/licenses/>. |
| 22 |
% ========================================================================= |
| 23 |
|
| 24 |
@#define TOL_RANK = 1e-10 |
| 25 |
|
| 26 |
var z g R y pie c piep yp; |
| 27 |
varexo e_z e_g e_R ; |
| 28 |
parameters tau betta nu phi pistar psi1 psi2 rhor rhog rhoz sig2r sig2g sig2z; |
| 29 |
|
| 30 |
tau = 2.0000; |
| 31 |
betta = 0.9975; |
| 32 |
nu = 0.1000; |
| 33 |
phi= 53.6797; |
| 34 |
pistar=1.0080^2; %note pistar is squared |
| 35 |
psi1 = 1.5000; |
| 36 |
psi2 = 0.1250; |
| 37 |
rhor = 0.7500; |
| 38 |
rhog = 0.9500; |
| 39 |
rhoz = 0.9000; |
| 40 |
sig2r= (.002^2)*(10^5); |
| 41 |
sig2g= (.006^2)*(10^5); |
| 42 |
sig2z=(.003^2)*(10^5); |
| 43 |
|
| 44 |
|
| 45 |
model; |
| 46 |
#kap=(tau*(1-nu))/(nu*phi*pistar); |
| 47 |
y = y(+1) + g - g(+1) - 1/tau*(R-pie(+1)-z(+1)); |
| 48 |
pie = betta*pie(+1)+kap*(y-g); |
| 49 |
c = y - g; |
| 50 |
R = rhor*R(-1)+(1-rhor)*psi1*pie+(1-rhor)*psi2*(y-g)+sqrt(sig2r)*e_R; |
| 51 |
g = rhog*g(-1)+sqrt(sig2g)*e_g; |
| 52 |
z = rhoz*z(-1)+sqrt(sig2z)*e_z; |
| 53 |
piep = pie(+1); |
| 54 |
yp = y(+1); |
| 55 |
end; |
| 56 |
|
| 57 |
estimated_params; |
| 58 |
tau, uniform_pdf, , , 1.5, 2.5; |
| 59 |
betta, uniform_pdf, , , 0.95, 0.99999; |
| 60 |
nu, uniform_pdf, , , 0.05, 0.5; |
| 61 |
phi, uniform_pdf, , , 10, 80; |
| 62 |
pistar, uniform_pdf, , , 1, 1.1; |
| 63 |
psi1, uniform_pdf, , , 1.05, 2.5; |
| 64 |
psi2, uniform_pdf, , , 0, 1.5; |
| 65 |
rhor, uniform_pdf, , , 0, 1; |
| 66 |
rhog, uniform_pdf, , , 0, 1; |
| 67 |
rhoz, uniform_pdf, , , 0, 1; |
| 68 |
sig2r, uniform_pdf, , , 0.01, 1; |
| 69 |
sig2g, uniform_pdf, , , 0.01, 1; |
| 70 |
sig2z, uniform_pdf, , , 0.01, 1; |
| 71 |
end; |
| 72 |
|
| 73 |
steady_state_model; |
| 74 |
pie=0; y=0; c=0; R=0; g=0; z=0; yp=0; piep=0; |
| 75 |
end; |
| 76 |
steady; |
| 77 |
check; |
| 78 |
|
| 79 |
varobs R y pie c; |
| 80 |
|
| 81 |
shocks; |
| 82 |
var e_z; |
| 83 |
stderr 1; |
| 84 |
var e_g; |
| 85 |
stderr 1; |
| 86 |
var e_R; |
| 87 |
stderr 1; |
| 88 |
end; |
| 89 |
|
| 90 |
identification(parameter_set=calibration, |
| 91 |
grid_nbr=10000, |
| 92 |
no_identification_strength, |
| 93 |
no_identification_reducedform, |
| 94 |
no_identification_moments, |
| 95 |
checks_via_subsets=1, |
| 96 |
tol_rank=@{TOL_RANK}, |
| 97 |
max_dim_subsets_groups=4); |
| 98 |
|
| 99 |
load('G_QT'); %note that this is computed using replication files of Qu and Tkachenko (2012) |
| 100 |
temp = load([M_.dname filesep 'identification' filesep M_.fname '_identif']); |
| 101 |
G_dynare = temp.ide_spectrum_point.dSPECTRUM; |
| 102 |
% Compare signs |
| 103 |
if ~isequal(sign(G_dynare),sign(G_QT)) |
| 104 |
error('signs of normalized G are note equal'); |
| 105 |
end |
| 106 |
|
| 107 |
% Compare normalized versions |
| 108 |
tilda_G_dynare = temp.ide_spectrum_point.tilda_dSPECTRUM; |
| 109 |
ind_G_QT = (find(max(abs(G_QT'),[],1) > temp.store_options_ident.tol_deriv)); |
| 110 |
tilda_G_QT = zeros(size(G_QT)); |
| 111 |
delta_G_QT = sqrt(diag(G_QT(ind_G_QT,ind_G_QT))); |
| 112 |
tilda_G_QT(ind_G_QT,ind_G_QT) = G_QT(ind_G_QT,ind_G_QT)./((delta_G_QT)*(delta_G_QT')); |
| 113 |
if ~isequal(rank(tilda_G_QT,@{TOL_RANK}),rank(tilda_G_dynare,@{TOL_RANK})) |
| 114 |
error('ranks are not the same for normalized version') |
| 115 |
end |
| 116 |
|
| 117 |
max(max(abs(abs(tilda_G_dynare)-abs(tilda_G_QT)))) |
| 118 |
norm(tilda_G_dynare - tilda_G_QT) |