Added the possibility to tag a varexo variable as an observed variable.

time-shift
Stéphane Adjemian (Charybdis) 2019-03-07 15:31:34 +01:00
parent 1471b3bfce
commit dac08da6a4
Signed by untrusted user who does not match committer: stepan
GPG Key ID: A6D44CB9C64CE77B
4 changed files with 126 additions and 1 deletions

View File

@ -0,0 +1,35 @@
function DynareModel = set_observed_exogenous_variables(DynareModel)
% Appends the list of observed exogenous variables in Dynare's model structure (if any).
%
% INPUTS
% - DynareModel [struct] Dynare's model global structure, M_.
%
% OUTPUTS
% - DynareModel [struct] Dynare's model global structure, M_.
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2019 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if isfield(DynareModel, 'exo_partitions')
if isfield(DynareModel.exo_partitions, 'status')
DynareModel.observed_exo_names = DynareModel.exo_names(strcmpi('observed', DynareModel.exo_partitions.status));
end
end

@ -1 +1 @@
Subproject commit 9b1b4113d9954c35f1c839f3657ff0b42f8fd6a9
Subproject commit 556789abce78c36d79b4ce6f0781f96ce111c43b

View File

@ -432,6 +432,7 @@ MODFILES = \
pac/trend-component-22/example.mod \
pac/trend-component-23/example.mod \
pac/trend-component-24/example.mod \
write/example1.mod \
ecb/backward-models/irf/solow_1.mod \
ecb/backward-models/irf/solow_2.mod \
dynare-command-options/ramst.mod

89
tests/write/example1.mod Normal file
View File

@ -0,0 +1,89 @@
// --+ options: json=compute, stochastic +--
var x1 x2 x1bar x2bar z y x;
varexo ex1
ex2
ex1bar
ex2bar
ez
ey (status='observed') // This shock is observed...
ex (status='observed') // ... this one also. Other shocks will be considered as non observed.
;
parameters
rho_1 rho_2 rho_3 rho_4
a_x1_0 a_x1_1 a_x1_2 a_x1_x2_1 a_x1_x2_2
a_x2_0 a_x2_1 a_x2_2 a_x2_x1_1 a_x2_x1_2
e_c_m c_z_1 c_z_2 beta
lambda;
rho_1 = .9;
rho_2 = -.2;
rho_3 = .4;
rho_4 = -.3;
a_x1_0 = -.9;
a_x1_1 = .4;
a_x1_2 = .3;
a_x1_x2_1 = .1;
a_x1_x2_2 = .2;
a_x2_0 = -.9;
a_x2_1 = .2;
a_x2_2 = -.1;
a_x2_x1_1 = -.1;
a_x2_x1_2 = .2;
beta = .2;
e_c_m = .5;
c_z_1 = .2;
c_z_2 = -.1;
lambda = 0.5; // Share of optimizing agents.
trend_component_model(model_name=toto, eqtags=['eq:x1', 'eq:x2', 'eq:x1bar', 'eq:x2bar'], targets=['eq:x1bar', 'eq:x2bar']);
pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman);
model;
[name='eq:y']
y = rho_1*y(-1) + rho_2*y(-2) + ey;
[name='eq:x']
x = rho_3*x(-1) + rho_4*x(-2) + ex;
[name='eq:x1']
diff(x1) = a_x1_0*(x1(-1)-x1bar(-1)) + a_x1_1*diff(x1(-1)) + a_x1_2*diff(x1(-2)) + a_x1_x2_1*diff(x2(-1)) + a_x1_x2_2*diff(x2(-2)) + ex1;
[name='eq:x2']
diff(x2) = a_x2_0*(x2(-1)-x2bar(-1)) + a_x2_1*diff(x1(-1)) + a_x2_2*diff(x1(-2)) + a_x2_x1_1*diff(x2(-1)) + a_x2_x1_2*diff(x2(-2)) + ex2;
[name='eq:x1bar']
x1bar = x1bar(-1) + ex1bar;
[name='eq:x2bar']
x2bar = x2bar(-1) + ex2bar;
[name='zpac']
diff(z) = lambda*(e_c_m*(x1(-1)-z(-1)) + c_z_1*diff(z(-1)) + c_z_2*diff(z(-2)) + pac_expectation(pacman)) + (1-lambda)*( y + x) + ez;
end;
shocks;
var ex1 = 1.0;
var ex2 = 1.0;
var ex1bar = 1.0;
var ex2bar = 1.0;
var ez = 1.0;
var ey = 0.1;
var ex = 0.1;
end;
verbatim;
if ~isequal(M_.observed_exo_names, {'ey'; 'ex'})
error()
end
end;