Add interface to flip endogenous and exogenous variables.
Calls to change_type can be done in a file named model-inversion-setup.inc in the current folder. The file is included, between the declaration of the exogenous variables and the model block, in the aggregate mod file if and only if the macrovariable InvertModel exists and is equal to True. To invert a model, the user just has to run the aggregated mod file with -DInvertModel=True on the command line.silicon
parent
996ab9613c
commit
6e0a09f5fa
|
@ -2,7 +2,7 @@ function aggregate(ofile, dynopt, rootfolder, varargin)
|
||||||
|
|
||||||
% Agregates cherry-picked models.
|
% Agregates cherry-picked models.
|
||||||
|
|
||||||
% Copyright © 2019-2021 Dynare Team
|
% Copyright © 2019-2023 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
|
@ -263,6 +263,7 @@ end
|
||||||
if ~isempty(firstline)
|
if ~isempty(firstline)
|
||||||
fprintf(fid, '%s\n\n', firstline);
|
fprintf(fid, '%s\n\n', firstline);
|
||||||
end
|
end
|
||||||
|
% Print list of endogenous variables.
|
||||||
fprintf(fid, 'var\n');
|
fprintf(fid, 'var\n');
|
||||||
for i=1:rows(elist)
|
for i=1:rows(elist)
|
||||||
if size(elist,2)==1 || isempty(elist{i,2})
|
if size(elist,2)==1 || isempty(elist{i,2})
|
||||||
|
@ -272,15 +273,18 @@ for i=1:rows(elist)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if ~isempty(plist)
|
if ~isempty(plist)
|
||||||
|
% Print list of parameters.
|
||||||
fprintf(fid, ';\n\n');
|
fprintf(fid, ';\n\n');
|
||||||
fprintf(fid, 'parameters\n');
|
fprintf(fid, 'parameters\n');
|
||||||
for i=1:length(plist)
|
for i=1:length(plist)
|
||||||
fprintf(fid, '\t%s\n', plist{i});
|
fprintf(fid, '\t%s\n', plist{i});
|
||||||
end
|
end
|
||||||
fprintf(fid, ';\n\n');
|
fprintf(fid, ';\n\n');
|
||||||
|
% Print calibration.
|
||||||
fprintf(fid, calibration);
|
fprintf(fid, calibration);
|
||||||
end
|
end
|
||||||
if ~isempty(xlist)
|
if ~isempty(xlist)
|
||||||
|
% Print list of exogenous variables.
|
||||||
fprintf(fid, '\n\n');
|
fprintf(fid, '\n\n');
|
||||||
fprintf(fid, 'varexo\n');
|
fprintf(fid, 'varexo\n');
|
||||||
for i=1:rows(xlist)
|
for i=1:rows(xlist)
|
||||||
|
@ -291,7 +295,17 @@ if ~isempty(xlist)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
fprintf(fid, ';\n\n');
|
fprintf(fid, ';\n');
|
||||||
|
skipline(1, fid)
|
||||||
|
% Provide an interface to flip endogenous and exogenous variables. Active if only macrovariable
|
||||||
|
% InvertModel is set to True. The calls to the change_type command must be provided in the file
|
||||||
|
% model-inversion-setup.inc (in the current folder).
|
||||||
|
fprintf(fid, '@#ifdef InvertModel\n');
|
||||||
|
fprintf(fid, ' @#if InvertModel\n');
|
||||||
|
fprintf(fid, ' @#include "model-inversion-setup.inc"\n');
|
||||||
|
fprintf(fid, ' @#endif\n');
|
||||||
|
fprintf(fid, '@#endif\n');
|
||||||
|
skipline(1, fid)
|
||||||
fprintf(fid, 'model;\n\n');
|
fprintf(fid, 'model;\n\n');
|
||||||
for i=1:rows(eqlist)
|
for i=1:rows(eqlist)
|
||||||
if isempty(eqlist{i,4})
|
if isempty(eqlist{i,4})
|
||||||
|
|
Loading…
Reference in New Issue