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
228b2a53
Commit
228b2a53
authored
5 years ago
by
Johannes Pfeifer
Browse files
Options
Downloads
Patches
Plain Diff
conditional forecasts: add check whether simulation was successful
parent
181725c7
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1708
conditional forecasts: add check whether simulation was successful
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
matlab/imcforecast.m
+5
-4
5 additions, 4 deletions
matlab/imcforecast.m
matlab/mcforecast3.m
+10
-8
10 additions, 8 deletions
matlab/mcforecast3.m
with
15 additions
and
12 deletions
matlab/imcforecast.m
+
5
−
4
View file @
228b2a53
...
...
@@ -204,9 +204,6 @@ if ~estimated_model
trend
=
repmat
(
ys
(
oo_
.
dr
.
order_var
,:),
1
,
options_cond_fcst
.
periods
+
1
);
%trend needs to contain correct steady state
end
NumberOfStates
=
length
(
InitState
);
FORCS1
=
zeros
(
NumberOfStates
,
options_cond_fcst
.
periods
+
1
,
options_cond_fcst
.
replic
);
...
...
@@ -252,7 +249,11 @@ for b=1:options_cond_fcst.replic %conditional forecast using cL set to constrain
[
FORCS1
(:,:,
b
),
FORCS1_shocks
(:,:,
b
)]
=
mcforecast3
(
cL
,
options_cond_fcst
.
periods
,
constrained_paths
,
shocks
,
FORCS1
(:,:,
b
),
T
,
R
,
mv
,
mu
);
FORCS1
(:,:,
b
)
=
FORCS1
(:,:,
b
)
+
trend
;
%add trend
end
if
max
(
max
(
max
(
abs
(
FORCS1
(
constrained_vars
,
1
:
cL
,:)
-
constrained_paths
))))
>
1e-4
fprintf
(
'\nconditional_forecasts: controlling of variables was not successful.\n'
)
fprintf
(
'This can be due to numerical imprecision (e.g. explosive simulations)\n'
)
fprintf
(
'or because the instrument(s) do not allow controlling the variable(s).\n'
)
end
mFORCS1
=
mean
(
FORCS1
,
3
);
mFORCS1_shocks
=
mean
(
FORCS1_shocks
,
3
);
...
...
This diff is collapsed.
Click to expand it.
matlab/mcforecast3.m
+
10
−
8
View file @
228b2a53
function
[
forcs
,
e
]
=
mcforecast3
(
cL
,
H
,
mcValue
,
shocks
,
forcs
,
T
,
R
,
mv
,
mu
)
% forcs = mcforecast3(cL,H,mcValue,shocks,forcs,T,R,mv,mu)
%
[
forcs
, e]
= mcforecast3(cL,H,mcValue,shocks,forcs,T,R,mv,mu)
% Computes the shock values for constrained forecasts necessary to keep
% endogenous variables at their constrained paths
%
...
...
@@ -7,13 +7,15 @@ function [forcs, e]= mcforecast3(cL,H,mcValue,shocks,forcs,T,R,mv,mu)
% o cL [scalar] number of controlled periods
% o H [scalar] number of forecast periods
% o mcValue [n_controlled_vars by cL double] paths for constrained variables
% o shocks [nexo by H double] shock values draws (with zeros for controlled_varexo)
% o forcs
% o T [n_endovars by n_endovars double] transition matrix of the state equation.
% o R [n_endovars by n_exo double] matrix relating the endogenous variables to the innovations in the state equation.
% o mv [n_controlled_exo by n_endovars boolean] indicator vector selecting constrained endogenous variables
% o mu [n_controlled_vars by nexo boolean] indicator vector
% selecting controlled exogenous variables
% o shocks [nexo by H double] shock values draws (with zeros for controlled_varexo)
% o forcs [n_endovars by H+1 double] matrix of endogenous variables storing the inital condition
% o T [n_endovars by n_endovars double] transition matrix of the state equation.
% o R [n_endovars by n_exo double] matrix relating the endogenous variables to the innovations in the state equation.
% o mv [n_controlled_exo by n_endovars boolean] indicator vector selecting constrained endogenous variables
% o mu [n_controlled_vars by nexo boolean] indicator vector selecting controlled exogenous variables
% OUTPUTS
% o forcs [n_endovars by H+1 double] matrix of forecasted endogenous variables
% o e [nexo by H double] matrix of exogenous variables
%
% Algorithm:
% Relies on state-space form:
...
...
This diff is collapsed.
Click to expand it.
Johannes Pfeifer
@JohannesPfeifer
mentioned in commit
dd67d486
·
5 years ago
mentioned in commit
dd67d486
mentioned in commit dd67d486307dd2813d78360d8ae652fadfb3e712
Toggle commit list
Sébastien Villemot
@sebastien
mentioned in commit
133b77c0
·
5 years ago
mentioned in commit
133b77c0
mentioned in commit 133b77c061a2e1937e38348a169b4c7d2954f2bf
Toggle commit list
Sébastien Villemot
@sebastien
mentioned in commit
9a4e7107
·
5 years ago
mentioned in commit
9a4e7107
mentioned in commit 9a4e7107c96743aaad9556d19e2b5290b60b54e9
Toggle commit list
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