Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dynare
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dynare
dynare
Commits
d3af0839
Commit
d3af0839
authored
4 years ago
by
MichelJuillard
Browse files
Options
Downloads
Patches
Plain Diff
fixes handling of periods in histval_file/initval_file
parent
6f0196be
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
matlab/histvalf.m
+0
-23
0 additions, 23 deletions
matlab/histvalf.m
matlab/histvalf_initvalf.m
+18
-0
18 additions, 0 deletions
matlab/histvalf_initvalf.m
tests/histval_initval_file/sim_exo_lead_lag_initvalf.mod
+77
-0
77 additions, 0 deletions
tests/histval_initval_file/sim_exo_lead_lag_initvalf.mod
with
95 additions
and
23 deletions
matlab/histvalf.m
+
0
−
23
View file @
d3af0839
...
...
@@ -30,29 +30,6 @@ function [endo_histval, exo_histval, exo_det_histval] = histvalf(M, options)
% 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
(
options
,
'nobs'
)
||
isempty
(
options
.
nobs
)
options
.
nobs
=
M
.
orig_maximum_lag
;
end
if
~
isfield
(
options
,
'first_obs'
)
||
isempty
(
options
.
first_obs
)
if
isfield
(
options
,
'first_simulation_period'
)
options
.
first_obs
=
options
.
first_simulation_period
...
-
options
.
nobs
;
else
options
.
first_obs
=
1
;
end
elseif
isfield
(
options
,
'first_simulation_period'
)
nobs
=
options
.
first_simulation_period
-
opions_
.
first_obs
;
if
options
.
nobs
~=
nobs
error
(
sprintf
([
'HISTVALF: first_obs = %d and'
,
...
' first_simulation_period = %d'
,
...
' don
''
t provide for the number of'
...
' lags in the model.'
],
...
options
.
first_obs
,
...
options
.
first_simulation_period
))
end
end
series
=
histvalf_initvalf
(
'HISTVAL'
,
M
,
options
);
% capture the difference between stochastic and
% perfect foresight setup
...
...
This diff is collapsed.
Click to expand it.
matlab/histvalf_initvalf.m
+
18
−
0
View file @
d3af0839
...
...
@@ -129,6 +129,24 @@ nobs0 = series.nobs;
first_obs_ispresent
=
false
;
last_obs_ispresent
=
false
;
if
~
isfield
(
options
,
'first_obs'
)
||
isempty
(
options
.
first_obs
)
if
isfield
(
options
,
'first_simulation_period'
)
options
.
first_obs
=
options
.
first_simulation_period
...
-
M
.
orig_maximum_lag
;
end
elseif
isfield
(
options
,
'first_simulation_period'
)
nobs
=
options
.
first_simulation_period
-
opions_
.
first_obs
;
if
M
.
orig_maximum_lag
~=
nobs
error
(
sprintf
([
'HISTVALF: first_obs = %d and'
,
...
' first_simulation_period = %d'
,
...
' don
''
t provide for the number of'
...
' lags in the model.'
],
...
options
.
first_obs
,
...
options
.
first_simulation_period
))
end
end
if
isfield
(
options
,
'first_obs'
)
i
=
options
.
first_obs
;
if
i
<
1
...
...
This diff is collapsed.
Click to expand it.
tests/histval_initval_file/sim_exo_lead_lag_initvalf.mod
+
77
−
0
View file @
d3af0839
...
...
@@ -24,6 +24,12 @@ model;
end;
initval_file(series = ds);
if oo_.initval_series.dates(1) ~= dates('1Y');
error("Wrong initial date in oo_.initval_series");
end;
if oo_.initval_series{'x'}.data(6) ~= 0.9;
error("Wrond value for x");
end;
perfect_foresight_setup(periods=200);
perfect_foresight_solver(maxit=100);
...
...
@@ -42,6 +48,55 @@ data1(8, 6) = 0.9; //shock to x in period 2
ds1 = dseries(data1, '1Y', {'c', 'cmav', 'k', 'z_backward', 'z_forward', 'x'});
initval_file(series = ds1, first_obs = 3, last_obs = 210, nobs = 208);
if oo_.initval_series.dates(1) ~= dates('1Y');
error("Wrong initial date in oo_.initval_series");
end;
if oo_.initval_series{'x'}.data(6) ~= 0.9;
error("Wrond value for x");
end;
perfect_foresight_setup(periods=200);
perfect_foresight_solver(maxit=100);
if ~oo_.deterministic_simulation.status
error('Perfect foresight simulation failed');
end
base_results=load('sim_exo_lead_lag_results.mat');
if max(max(abs(base_results.oo_.endo_simul(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8
error('Simulation with leads and lags doesn''t match the one with auxiliary variables')
end
initval_file(series = ds1, first_obs = 3Y, last_obs = 210Y, nobs = 208);
if oo_.initval_series.dates(1) ~= dates('3Y');
error("Wrong initial date in oo_.initval_series");
end;
if oo_.initval_series{'x'}.data(6) ~= 0.9;
error("Wrond value for x");
end;
perfect_foresight_setup(periods=200);
perfect_foresight_solver(maxit=100);
if ~oo_.deterministic_simulation.status
error('Perfect foresight simulation failed');
end
base_results=load('sim_exo_lead_lag_results.mat');
if max(max(abs(base_results.oo_.endo_simul(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8
error('Simulation with leads and lags doesn''t match the one with auxiliary variables')
end
initval_file(series = ds1, first_simulation_period = 7);
if oo_.initval_series.dates(1) ~= dates('1Y');
error("Wrong initial date in oo_.initval_series");
end;
if oo_.initval_series{'x'}.data(6) ~= 0.9;
error("Wrond value for x");
end;
perfect_foresight_setup(periods=200);
perfect_foresight_solver(maxit=100);
...
...
@@ -54,3 +109,25 @@ base_results=load('sim_exo_lead_lag_results.mat');
if max(max(abs(base_results.oo_.endo_simul(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8
error('Simulation with leads and lags doesn''t match the one with auxiliary variables')
end
initval_file(series = ds1, first_simulation_period = 7Y);
if oo_.initval_series.dates(1) ~= dates('1Y');
error("Wrong initial date in oo_.initval_series");
end;
if oo_.initval_series{'x'}.data(6) ~= 0.9;
error("Wrond value for x");
end;
perfect_foresight_setup(periods=200);
perfect_foresight_solver(maxit=100);
if ~oo_.deterministic_simulation.status
error('Perfect foresight simulation failed');
end
base_results=load('sim_exo_lead_lag_results.mat');
if max(max(abs(base_results.oo_.endo_simul(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8
error('Simulation with leads and lags doesn''t match the one with auxiliary variables')
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment