Remove aux variables from evaluate routine.

Auxiliary variables were still present in the growth neutrality correction. This
commit remove the auxiliaries, so that the user doesn't need to update the
database with the auxiliary variable definitions.

Also adds integration test.

TODO Check that it works with log unary op
TODO Complete tests by checking that the written evaluate routine works
evaluate-with-growth-neutrality-correction
Stéphane Adjemian (Charybdis) 2022-01-13 19:09:18 +01:00 committed by Stéphane Adjemian (Ryûk)
parent bab2b983c8
commit e1d0ce28d2
Signed by: stepan
GPG Key ID: 295C1FE89E17EB3C
21 changed files with 568 additions and 26 deletions

View File

@ -299,23 +299,7 @@ for i=1:maxlag
for j=1:length(auxmodel.list_of_variables_in_companion_var)
id = id+1;
variable = auxmodel.list_of_variables_in_companion_var{j};
transformations = {};
ida = get_aux_variable_id(variable);
op = 0;
while ida
op = op+1;
if isequal(M_.aux_vars(ida).type, 8)
transformations(op) = {'diff'};
variable = M_.endo_names{M_.aux_vars(ida).orig_index};
ida = get_aux_variable_id(variable);
elseif isequal(M_.aux_vars(ida).type, 10)
transformations(op) = {M_.aux_vars(ida).unary_op};
variable = M_.endo_names{M_.aux_vars(ida).orig_index};
ida = get_aux_variable_id(variable);
else
error('This case is not implemented.')
end
end
[variable, transformations] = rewrite_aux_variable(variable, M_);
switch expectationmodelkind
case 'var'
parameter = M_.params(expectationmodel.param_indices(id));
@ -378,13 +362,31 @@ if isequal(expectationmodelkind, 'pac') && growth_correction
for iter = 1:numel(expectationmodel.growth_linear_comb)
vgrowth='';
if expectationmodel.growth_linear_comb(iter).exo_id > 0
vgrowth = strcat('dbase.', M_.exo_names{expectationmodel.growth_linear_comb(iter).exo_id});
variable = M_.exo_names{expectationmodel.growth_linear_comb(iter).exo_id};
elseif expectationmodel.growth_linear_comb(iter).endo_id > 0
vgrowth = strcat('dbase.', M_.endo_names{expectationmodel.growth_linear_comb(iter).endo_id});
variable = M_.endo_names{expectationmodel.growth_linear_comb(iter).endo_id};
end
if expectationmodel.growth_linear_comb(iter).lag ~= 0
vgrowth = sprintf('%s(%d)', vgrowth, expectationmodel.growth_linear_comb(iter).lag);
[variable, transformations] = rewrite_aux_variable(variable, M_);
if isempty(transformations)
if expectationmodel.growth_linear_comb(iter).lag ~= 0
variable = sprintf('%s(%d)', variable, expectationmodel.growth_linear_comb(iter).lag);
end
else
for k=rows(transformations):-1:1
if isequal(transformations{k,1}, 'lag')
variable = sprintf('%s.lag(%u)', variable, -transformations{k,2});
elseif isequal(transformations{k,1}, 'diff')
if isempty(transformations{k,2})
variable = sprintf('%s.%s()', variable, transformations{k,1});
else
variable = sprintf('%s(-%u).%s()', variable, transformations{k,2}, transformations{k,1});
end
else
variable = sprintf('%s.%s()', variable, transformations{k});
end
end
end
vgrowth = strcat('dbase.', variable);
if expectationmodel.growth_linear_comb(iter).param_id > 0
if ~isempty(vgrowth)
vgrowth = sprintf('%1.16f*%s',M_.params(expectationmodel.growth_linear_comb(iter).param_id), vgrowth);
@ -418,14 +420,31 @@ if isequal(expectationmodelkind, 'pac') && growth_correction
for iter = 1:numel(expectationmodel.components(i).growth_linear_comb)
vgrowth='';
if expectationmodel.components(i).growth_linear_comb(iter).exo_id > 0
vgrowth = strcat('dbase.', M_.exo_names{expectationmodel.components(i).growth_linear_comb(iter).exo_id});
variable = M_.exo_names{expectationmodel.components(i).growth_linear_comb(iter).exo_id};
elseif expectationmodel.components(i).growth_linear_comb(iter).endo_id > 0
vgrowth = strcat('dbase.', M_.endo_names{expectationmodel.components(i).growth_linear_comb(iter).endo_id});
% TODO Check if we should not substitute auxiliary variables with original transformed variables here.
variable = M_.endo_names{expectationmodel.components(i).growth_linear_comb(iter).endo_id};
end
if expectationmodel.components(i).growth_linear_comb(iter).lag ~= 0
vgrowth = sprintf('%s(%d)', vgrowth, expectationmodel.components(i).growth_linear_comb(iter).lag);
[variable, transformations] = rewrite_aux_variable(variable, M_);
if isempty(transformations)
if expectationmodel.components(i).growth_linear_comb(iter).lag ~= 0
variable = sprintf('%s(%d)', variable, expectationmodel.components(i).growth_linear_comb(iter).lag);
end
else
for k=rows(transformations):-1:1
if isequal(transformations{k,1}, 'lag')
variable = sprintf('%s.lag(%u)', variable, -transformations{k,2});
elseif isequal(transformations{k,1}, 'diff')
if isempty(transformations{k,2})
variable = sprintf('%s.%s()', variable, transformations{k,1});
else
variable = sprintf('%s(-%u).%s()', variable, transformations{k,2}, transformations{k,1});
end
else
variable = sprintf('%s.%s()', variable, transformations{k});
end
end
end
vgrowth = strcat('dbase.', variable);
if expectationmodel.components(i).growth_linear_comb(iter).param_id > 0
if ~isempty(vgrowth)
vgrowth = sprintf('%1.16f*%s',M_.params(expectationmodel.components(i).growth_linear_comb(iter).param_id), vgrowth);

View File

@ -0,0 +1,47 @@
function [variable, transformations] = rewrite_aux_variable(variable, M_)
% Copyright © 2021 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 <https://www.gnu.org/licenses/>.
transformations = {};
ida = get_aux_variable_id(variable);
op = 0;
dl = 0;
while ida
op = op+1;
if isequal(M_.aux_vars(ida).type, 1)
transformations(op,1) = {'lag'};
transformations(op,2) = {M_.aux_vars(ida).orig_lead_lag-1};
variable = M_.endo_names{M_.aux_vars(ida).orig_index};
elseif isequal(M_.aux_vars(ida).type, 8)
transformations(op, 1) = {'diff'};
variable = M_.endo_names{M_.aux_vars(ida).orig_index};
elseif isequal(M_.aux_vars(ida).type, 9)
dl = dl+1;
transformations(op, 1) = {'lag'};
transformations(op, 2) = {dl};
op = op-1;
variable = M_.endo_names{M_.aux_vars(ida).orig_index};
elseif isequal(M_.aux_vars(ida).type, 10)
transformations(op, 1) = {M_.aux_vars(ida).unary_op};
variable = M_.endo_names{M_.aux_vars(ida).orig_index};
else
error('This case is not implemented.')
end
ida = get_aux_variable_id(variable);
end

View File

@ -529,6 +529,10 @@ ECB_MODFILES = \
pac/var-10e/example1.mod \
pac/var-10e/example2.mod \
pac/var-11e/example1.mod \
pac/var-12/example1.mod \
pac/var-12/example2.mod \
pac/var-12/example11.mod \
pac/var-12/example12.mod \
pac/trend-component-1/example1.mod \
pac/trend-component-2/example1.mod \
pac/trend-component-3/example1.mod \

View File

@ -0,0 +1,74 @@
// --+ options: json=compute, stochastic +--
var y x z v;
varexo ex ey ez ;
parameters a_y_1 a_y_2 b_y_1 b_y_2 b_x_1 b_x_2 d_y; // VAR parameters
parameters beta e_c_m c_z_1 c_z_2; // PAC equation parameters
a_y_1 = .2;
a_y_2 = .3;
b_y_1 = .1;
b_y_2 = .4;
b_x_1 = -.1;
b_x_2 = -.2;
d_y = .5;
beta = .9;
e_c_m = .1;
c_z_1 = .7;
c_z_2 = -.3;
var_model(model_name=toto, structural, eqtags=['eq:x', 'eq:y']);
pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman);
pac_target_info(pacman);
target v;
auxname_target_nonstationary vns;
component y;
auxname pv_y_;
kind ll;
component x;
growth diff(x(-2));
auxname pv_dx_;
kind dd;
end;
model;
[name='eq:y']
y = a_y_1*y(-1) + a_y_2*diff(x(-1)) + b_y_1*y(-2) + b_y_2*diff(x(-2)) + ey ;
[name='eq:x']
diff(x) = b_x_1*y(-2) + b_x_2*diff(x(-1)) + ex ;
[name='eq:v']
v = x + d_y*y ;
[name='eq:pac']
diff(z) = e_c_m*(pac_target_nonstationary(pacman)-z(-1)) + c_z_1*diff(z(-1)) + c_z_2*diff(z(-2)) + pac_expectation(pacman) + ez;
end;
shocks;
var ex = 1.0;
var ey = 1.0;
var ez = 1.0;
end;
// Initialize the PAC model (build the Companion VAR representation for the auxiliary model).
pac.initialize('pacman');
// Update the parameters of the PAC expectation model (h0 and h1 vectors).
pac.update.expectation('pacman');
// Print expanded PAC_EXPECTATION term.
pac.print('pacman', 'eq:pac');

View File

@ -0,0 +1,5 @@
// This file has been generated by dynare (14-Jan-2022 17:56:36).
d_y*h_pacman_component1_constant+h_pacman_component2_constant + (d_y*h_pacman_component1_var_AUX_DIFF_11_lag_1+h_pacman_component2_var_AUX_DIFF_11_lag_1)*diff(x(-1))
+ (d_y*h_pacman_component1_var_y_lag_1+h_pacman_component2_var_y_lag_1)*y(-1)
+ (d_y*h_pacman_component1_var_AUX_DIFF_11_lag_2+h_pacman_component2_var_AUX_DIFF_11_lag_2)*diff(x(-2))
+ (d_y*h_pacman_component1_var_y_lag_2+h_pacman_component2_var_y_lag_2)*y(-2)

View File

@ -0,0 +1,2 @@
// This file has been generated by dynare (14-Jan-2022 17:56:36).
pacman_component2_pac_growth_neutrality_correction*diff(x(-2))

View File

@ -0,0 +1,18 @@
// This file has been generated by dynare (14-Jan-2022 17:56:36).
parameters h_pacman_component1_constant h_pacman_component1_var_AUX_DIFF_11_lag_1 h_pacman_component1_var_y_lag_1 h_pacman_component1_var_AUX_DIFF_11_lag_2 h_pacman_component1_var_y_lag_2 h_pacman_component2_constant h_pacman_component2_var_AUX_DIFF_11_lag_1 h_pacman_component2_var_y_lag_1 h_pacman_component2_var_AUX_DIFF_11_lag_2 h_pacman_component2_var_y_lag_2;
h_pacman_component1_constant = 0.0000000000000000;
h_pacman_component1_var_AUX_DIFF_11_lag_1 = 0.0145990564819670;
h_pacman_component1_var_y_lag_1 = 0.0060141756634789;
h_pacman_component1_var_AUX_DIFF_11_lag_2 = 0.0088556033620678;
h_pacman_component1_var_y_lag_2 = 0.0007072909429702;
h_pacman_component2_constant = 0.0000000000000000;
h_pacman_component2_var_AUX_DIFF_11_lag_1 = -0.0204386323060280;
h_pacman_component2_var_y_lag_1 = -0.0090103235508248;
h_pacman_component2_var_AUX_DIFF_11_lag_2 = -0.0026679701308692;
h_pacman_component2_var_y_lag_2 = -0.0089540800364464;
parameters pacman_component2_pac_growth_neutrality_correction;
pacman_component2_pac_growth_neutrality_correction = 0.1853271645736974;

View File

@ -0,0 +1,55 @@
// --+ options: json=compute, stochastic +--
var y x z;
varexo ex ey ez ;
parameters a_y_1 a_y_2 b_y_1 b_y_2 b_x_1 b_x_2 d_y; // VAR parameters
parameters beta e_c_m c_z_1 c_z_2; // PAC equation parameters
a_y_1 = .2;
a_y_2 = .3;
b_y_1 = .1;
b_y_2 = .4;
b_x_1 = -.1;
b_x_2 = -.2;
d_y = .5;
beta = .9;
e_c_m = .1;
c_z_1 = .7;
c_z_2 = -.3;
var_model(model_name=toto, structural, eqtags=['eq:x', 'eq:y']);
pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman, growth=diff(x(-2)));
model;
[name='eq:y']
y = a_y_1*y(-1) + a_y_2*diff(x(-1)) + b_y_1*y(-2) + b_y_2*diff(x(-2)) + ey ;
[name='eq:x']
diff(x) = b_x_1*y(-2) + b_x_2*diff(x(-1)) + ex ;
[name='eq:pac']
diff(z) = e_c_m*(x(-1)-z(-1)) + c_z_1*diff(z(-1)) + c_z_2*diff(z(-2)) + pac_expectation(pacman) + ez;
end;
shocks;
var ex = 1.0;
var ey = 1.0;
var ez = 1.0;
end;
// Initialize the PAC model (build the Companion VAR representation for the auxiliary model).
pac.initialize('pacman');
// Update the parameters of the PAC expectation model (h0 and h1 vectors).
pac.update.expectation('pacman');
// Print expanded PAC_EXPECTATION term.
pac.print('pacman', 'eq:pac');

View File

@ -0,0 +1,5 @@
// This file has been generated by dynare (14-Jan-2022 19:06:42).
h_pacman_constant + h_pacman_var_AUX_DIFF_31_lag_1*diff(x(-1))
+ h_pacman_var_y_lag_1*y(-1)
+ h_pacman_var_AUX_DIFF_31_lag_2*diff(x(-2))
+ h_pacman_var_y_lag_2*y(-2)

View File

@ -0,0 +1,2 @@
// This file has been generated by dynare (14-Jan-2022 19:06:42).
pacman_pac_growth_neutrality_correction*diff(x(-2))

View File

@ -0,0 +1,13 @@
// This file has been generated by dynare (14-Jan-2022 19:06:42).
parameters h_pacman_constant h_pacman_var_AUX_DIFF_31_lag_1 h_pacman_var_y_lag_1 h_pacman_var_AUX_DIFF_31_lag_2 h_pacman_var_y_lag_2;
h_pacman_constant = 0.0000000000000000;
h_pacman_var_AUX_DIFF_31_lag_1 = -0.0204386323060280;
h_pacman_var_y_lag_1 = -0.0090103235508248;
h_pacman_var_AUX_DIFF_31_lag_2 = -0.0026679701308692;
h_pacman_var_y_lag_2 = -0.0089540800364464;
parameters pacman_pac_growth_neutrality_correction;
pacman_pac_growth_neutrality_correction = 0.1853271645736974;

View File

@ -0,0 +1,56 @@
// --+ options: json=compute, stochastic +--
var y x z;
varexo ex ey ez ;
parameters a_y_1 a_y_2 b_y_1 b_y_2 b_x_1 b_x_2 d_y; // VAR parameters
parameters beta e_c_m c_z_1 c_z_2; // PAC equation parameters
a_y_1 = .2;
a_y_2 = .3;
b_y_1 = .1;
b_y_2 = .4;
b_x_1 = -.1;
b_x_2 = -.2;
d_y = .5;
beta = .9;
e_c_m = .1;
c_z_1 = .7;
c_z_2 = -.3;
var_model(model_name=toto, structural, eqtags=['eq:x', 'eq:y']);
pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman, growth=x(-2));
model;
[name='eq:y']
y = a_y_1*y(-1) + a_y_2*diff(x(-1)) + b_y_1*y(-2) + b_y_2*diff(x(-2)) + ey ;
[name='eq:x']
diff(x) = b_x_1*y(-2) + b_x_2*diff(x(-1)) + ex ;
[name='eq:pac']
diff(z) = e_c_m*(x(-1)-z(-1)) + c_z_1*diff(z(-1)) + c_z_2*diff(z(-2)) + pac_expectation(pacman) + ez;
end;
shocks;
var ex = 1.0;
var ey = 1.0;
var ez = 1.0;
end;
// Initialize the PAC model (build the Companion VAR representation for the auxiliary model).
pac.initialize('pacman');
// Update the parameters of the PAC expectation model (h0 and h1 vectors).
pac.update.expectation('pacman');
// Print expanded PAC_EXPECTATION term.
pac.print('pacman', 'eq:pac');

View File

@ -0,0 +1,5 @@
// This file has been generated by dynare (14-Jan-2022 19:11:08).
h_pacman_constant + h_pacman_var_AUX_DIFF_31_lag_1*diff(x(-1))
+ h_pacman_var_y_lag_1*y(-1)
+ h_pacman_var_AUX_DIFF_31_lag_2*diff(x(-2))
+ h_pacman_var_y_lag_2*y(-2)

View File

@ -0,0 +1,2 @@
// This file has been generated by dynare (14-Jan-2022 19:11:08).
pacman_pac_growth_neutrality_correction*x(-2)

View File

@ -0,0 +1,13 @@
// This file has been generated by dynare (14-Jan-2022 19:11:08).
parameters h_pacman_constant h_pacman_var_AUX_DIFF_31_lag_1 h_pacman_var_y_lag_1 h_pacman_var_AUX_DIFF_31_lag_2 h_pacman_var_y_lag_2;
h_pacman_constant = 0.0000000000000000;
h_pacman_var_AUX_DIFF_31_lag_1 = -0.0204386323060280;
h_pacman_var_y_lag_1 = -0.0090103235508248;
h_pacman_var_AUX_DIFF_31_lag_2 = -0.0026679701308692;
h_pacman_var_y_lag_2 = -0.0089540800364464;
parameters pacman_pac_growth_neutrality_correction;
pacman_pac_growth_neutrality_correction = 0.1853271645736974;

View File

@ -0,0 +1,55 @@
// --+ options: json=compute, stochastic +--
var y x z;
varexo ex ey ez ;
parameters a_y_1 a_y_2 b_y_1 b_y_2 b_x_1 b_x_2 d_y; // VAR parameters
parameters beta e_c_m c_z_1 c_z_2; // PAC equation parameters
a_y_1 = .2;
a_y_2 = .3;
b_y_1 = .1;
b_y_2 = .4;
b_x_1 = -.1;
b_x_2 = -.2;
d_y = .5;
beta = .9;
e_c_m = .1;
c_z_1 = .7;
c_z_2 = -.3;
var_model(model_name=toto, structural, eqtags=['eq:x', 'eq:y']);
pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman, growth=diff(log(x(-2))));
model;
[name='eq:y']
y = a_y_1*y(-1) + a_y_2*diff(log(x(-1))) + b_y_1*y(-2) + b_y_2*diff(log(x(-2))) + ey ;
[name='eq:x']
diff(log(x)) = b_x_1*y(-2) + b_x_2*diff(log(x(-1))) + ex ;
[name='eq:pac']
diff(log(z)) = e_c_m*(log(x(-1))-log(z(-1))) + c_z_1*diff(log(z(-1))) + c_z_2*diff(log(z(-2))) + pac_expectation(pacman) + ez;
end;
shocks;
var ex = 1.0;
var ey = 1.0;
var ez = 1.0;
end;
// Initialize the PAC model (build the Companion VAR representation for the auxiliary model).
pac.initialize('pacman');
// Update the parameters of the PAC expectation model (h0 and h1 vectors).
pac.update.expectation('pacman');
// Print expanded PAC_EXPECTATION term.
pac.print('pacman', 'eq:pac');

View File

@ -0,0 +1,74 @@
// --+ options: json=compute, stochastic +--
var y x z v;
varexo ex ey ez ;
parameters a_y_1 a_y_2 b_y_1 b_y_2 b_x_1 b_x_2 d_y; // VAR parameters
parameters beta e_c_m c_z_1 c_z_2; // PAC equation parameters
a_y_1 = .2;
a_y_2 = .3;
b_y_1 = .1;
b_y_2 = .4;
b_x_1 = -.1;
b_x_2 = -.2;
d_y = .5;
beta = .9;
e_c_m = .1;
c_z_1 = .7;
c_z_2 = -.3;
var_model(model_name=toto, structural, eqtags=['eq:x', 'eq:y']);
pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman);
pac_target_info(pacman);
target v;
auxname_target_nonstationary vns;
component y;
auxname pv_y_;
kind ll;
component x;
growth x(-2);
auxname pv_dx_;
kind dd;
end;
model;
[name='eq:y']
y = a_y_1*y(-1) + a_y_2*diff(x(-1)) + b_y_1*y(-2) + b_y_2*diff(x(-2)) + ey ;
[name='eq:x']
diff(x) = b_x_1*y(-2) + b_x_2*diff(x(-1)) + ex ;
[name='eq:v']
v = x + d_y*y ;
[name='eq:pac']
diff(z) = e_c_m*(pac_target_nonstationary(pacman)-z(-1)) + c_z_1*diff(z(-1)) + c_z_2*diff(z(-2)) + pac_expectation(pacman) + ez;
end;
shocks;
var ex = 1.0;
var ey = 1.0;
var ez = 1.0;
end;
// Initialize the PAC model (build the Companion VAR representation for the auxiliary model).
pac.initialize('pacman');
// Update the parameters of the PAC expectation model (h0 and h1 vectors).
pac.update.expectation('pacman');
// Print expanded PAC_EXPECTATION term.
pac.print('pacman', 'eq:pac');

View File

@ -0,0 +1,5 @@
// This file has been generated by dynare (14-Jan-2022 17:58:52).
d_y*h_pacman_component1_constant+h_pacman_component2_constant + (d_y*h_pacman_component1_var_AUX_DIFF_11_lag_1+h_pacman_component2_var_AUX_DIFF_11_lag_1)*diff(x(-1))
+ (d_y*h_pacman_component1_var_y_lag_1+h_pacman_component2_var_y_lag_1)*y(-1)
+ (d_y*h_pacman_component1_var_AUX_DIFF_11_lag_2+h_pacman_component2_var_AUX_DIFF_11_lag_2)*diff(x(-2))
+ (d_y*h_pacman_component1_var_y_lag_2+h_pacman_component2_var_y_lag_2)*y(-2)

View File

@ -0,0 +1,2 @@
// This file has been generated by dynare (14-Jan-2022 17:58:52).
pacman_component2_pac_growth_neutrality_correction*x(-2)

View File

@ -0,0 +1,18 @@
// This file has been generated by dynare (14-Jan-2022 17:58:52).
parameters h_pacman_component1_constant h_pacman_component1_var_AUX_DIFF_11_lag_1 h_pacman_component1_var_y_lag_1 h_pacman_component1_var_AUX_DIFF_11_lag_2 h_pacman_component1_var_y_lag_2 h_pacman_component2_constant h_pacman_component2_var_AUX_DIFF_11_lag_1 h_pacman_component2_var_y_lag_1 h_pacman_component2_var_AUX_DIFF_11_lag_2 h_pacman_component2_var_y_lag_2;
h_pacman_component1_constant = 0.0000000000000000;
h_pacman_component1_var_AUX_DIFF_11_lag_1 = 0.0145990564819670;
h_pacman_component1_var_y_lag_1 = 0.0060141756634789;
h_pacman_component1_var_AUX_DIFF_11_lag_2 = 0.0088556033620678;
h_pacman_component1_var_y_lag_2 = 0.0007072909429702;
h_pacman_component2_constant = 0.0000000000000000;
h_pacman_component2_var_AUX_DIFF_11_lag_1 = -0.0204386323060280;
h_pacman_component2_var_y_lag_1 = -0.0090103235508248;
h_pacman_component2_var_AUX_DIFF_11_lag_2 = -0.0026679701308692;
h_pacman_component2_var_y_lag_2 = -0.0089540800364464;
parameters pacman_component2_pac_growth_neutrality_correction;
pacman_component2_pac_growth_neutrality_correction = 0.1853271645736974;

View File

@ -0,0 +1,68 @@
// --+ options: json=compute, stochastic +--
var y x z v;
varexo ex ey ez ;
parameters a_y_1 a_y_2 b_y_1 b_y_2 b_x_1 b_x_2 d_y; // VAR parameters
parameters beta e_c_m c_z_1 c_z_2; // PAC equation parameters
a_y_1 = .2;
a_y_2 = .3;
b_y_1 = .1;
b_y_2 = .4;
b_x_1 = -.1;
b_x_2 = -.2;
d_y = .5;
beta = .9;
e_c_m = .1;
c_z_1 = .7;
c_z_2 = -.3;
var_model(model_name=toto, structural, eqtags=['eq:x', 'eq:y']);
pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman);
pac_target_info(pacman);
target v;
auxname_target_nonstationary vns;
component y;
auxname pv_y_;
kind ll;
component log(x);
growth diff(log(x(-2)));
auxname pv_dx_;
kind dd;
end;
model;
[name='eq:y']
y = a_y_1*y(-1) + a_y_2*diff(log(x(-1))) + b_y_1*y(-2) + b_y_2*diff(log(x(-2))) + ey ;
[name='eq:x']
diff(log(x)) = b_x_1*y(-2) + b_x_2*diff(log(x(-1))) + ex ;
[name='eq:v']
v = log(x) + d_y*y ;
[name='eq:pac']
diff(z) = e_c_m*(pac_target_nonstationary(pacman)-z(-1)) + c_z_1*diff(z(-1)) + c_z_2*diff(z(-2)) + pac_expectation(pacman) + ez;
end;
// Initialize the PAC model (build the Companion VAR representation for the auxiliary model).
pac.initialize('pacman');
// Update the parameters of the PAC expectation model (h0 and h1 vectors).
pac.update.expectation('pacman');
// Print expanded PAC_EXPECTATION term.
pac.print('pacman', 'eq:pac');