commit
ef5f25c17a
|
@ -1,5 +1,5 @@
|
|||
function simulation = simul_backward_model(initialconditions, samplesize, innovations)
|
||||
|
||||
% function simulation = simul_backward_model(initialconditions, samplesize, innovations)
|
||||
% Simulates a stochastic backward looking model (with arbitrary precision).
|
||||
%
|
||||
% INPUTS
|
||||
|
@ -16,7 +16,7 @@ function simulation = simul_backward_model(initialconditions, samplesize, innova
|
|||
% [2] The last input argument is not mandatory. If absent we use random draws and rescale them with the informations provided
|
||||
% through the shocks block.
|
||||
% [3] If the first input argument is empty, the endogenous variables are initialized with 0, or if available with the informations
|
||||
% provided thrtough the histval block.
|
||||
% provided through the histval block.
|
||||
|
||||
% Copyright © 2012-2022 Dynare Team
|
||||
%
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
function simulations = simul_backward_nonlinear_model(initialconditions, samplesize, DynareOptions, DynareModel, DynareOutput, innovations)
|
||||
|
||||
% function simulations = simul_backward_nonlinear_model(initialconditions, samplesize, DynareOptions, DynareModel, DynareOutput, innovations)
|
||||
% Simulates a stochastic non linear backward looking model with arbitrary precision (a deterministic solver is used).
|
||||
%
|
||||
% INPUTS
|
||||
|
@ -11,7 +11,7 @@ function simulations = simul_backward_nonlinear_model(initialconditions, samples
|
|||
% - innovations [double] T*q matrix, innovations to be used for the simulation.
|
||||
%
|
||||
% OUTPUTS
|
||||
% - DynareOutput [struct] Dynare's oo_ global structure.
|
||||
% - simulation [dseries] Simulated endogenous and exogenous variables.
|
||||
%
|
||||
% REMARKS
|
||||
% [1] The innovations used for the simulation are saved in DynareOutput.exo_simul, and the resulting paths for the endogenous
|
||||
|
|
|
@ -1,21 +1,24 @@
|
|||
function [endogenousvariables, exogenousvariables] = model_inversion(constraints, ...
|
||||
exogenousvariables, ...
|
||||
initialconditions, DynareModel, DynareOptions, DynareOutput)
|
||||
|
||||
% function [endogenousvariables, exogenousvariables] = model_inversion(constraints, ...
|
||||
% exogenousvariables, ...
|
||||
% initialconditions, DynareModel, DynareOptions, DynareOutput)
|
||||
% INPUTS
|
||||
% - constraints [dseries] with N constrained endogenous variables from t1 to t2.
|
||||
% - exogenousvariables [dseries] with Q exogenous variables.
|
||||
% - initialconditions [dseries] with M endogenous variables starting before t1 (M initialcond must contain at least the state variables).
|
||||
% - DynareModel [struct] M_, Dynare global structure containing informations related to the model.
|
||||
% - DynareOptions [struct] options_, Dynare global structure containing all the options.
|
||||
% - DynareOutput [struct] oo_, Dynare global structure containing all the options.
|
||||
%
|
||||
% OUTPUTS
|
||||
% - endogenous [dseries]
|
||||
% - exogenous [dseries]
|
||||
% - endogenousvariables [dseries]
|
||||
% - exogenousvariables [dseries]
|
||||
%
|
||||
% REMARKS
|
||||
|
||||
% Copyright © 2018-2019 Dynare Team
|
||||
% Copyright © 2018-2021 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
|
|
@ -113,6 +113,12 @@ TruePopulation = TrueData.Population;
|
|||
TrueEfficiencyTimesPopulation = TrueEfficiency*TruePopulation;
|
||||
EfficiencyTimesPopulation = endogenousvariables.Efficiency*endogenousvariables.Population;
|
||||
|
||||
if max(abs(TrueEfficiencyTimesPopulation(2Y:100Y).data-EfficiencyTimesPopulation(2Y:100Y).data))>1e-5
|
||||
error('Model inversion is not consitent with true innovations.')
|
||||
if isoctave
|
||||
tolerance=2e-5;
|
||||
else
|
||||
tolerance=1e-5;
|
||||
end
|
||||
|
||||
if max(abs(TrueEfficiencyTimesPopulation(2Y:100Y).data-EfficiencyTimesPopulation(2Y:100Y).data))>tolerance
|
||||
error('Model inversion is not consistent with true innovations.')
|
||||
end
|
||||
|
|
|
@ -70,8 +70,12 @@ steady;
|
|||
|
||||
check;
|
||||
|
||||
TrueData = simul_backward_model([], 200);
|
||||
if isoctave
|
||||
options_.bnlms.set_dynare_seed_to_default=false;
|
||||
set_dynare_seed(1);
|
||||
end
|
||||
|
||||
TrueData = simul_backward_model([], 200);
|
||||
// Set the periods where some of the endogenous variables will be constrained.
|
||||
subsample = 3Y:100Y;
|
||||
|
||||
|
@ -93,11 +97,11 @@ if max(abs(constrainedpaths(subsample).y1.data-endogenousvariables(subsample).y1
|
|||
end
|
||||
|
||||
if max(abs(exogenousvariables(subsample).e2.data-SimulatedData(subsample).e2.data))>1e-12
|
||||
error('Constraint on e1 path is not satisfied!')
|
||||
error('Constraint on e2 path is not satisfied!')
|
||||
end
|
||||
|
||||
if max(abs(exogenousvariables(subsample).e3.data-SimulatedData(subsample).e3.data))>1e-12
|
||||
error('Constraint on e2 path is not satisfied!')
|
||||
error('Constraint on e3 path is not satisfied!')
|
||||
end
|
||||
|
||||
// Check consistency of the results.
|
||||
|
@ -110,5 +114,5 @@ if max(abs(SimulatedData(subsample).y3.data-endogenousvariables(subsample).y3.da
|
|||
end
|
||||
|
||||
if max(abs(exogenousvariables(subsample).e1.data-SimulatedData(subsample).e1.data))>1e-12
|
||||
error('Model inversion is not consistent with true innovations (e3)')
|
||||
error('Model inversion is not consistent with true innovations (e1)')
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue