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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dóra Kocsis
dynare
Commits
fb127d01
Commit
fb127d01
authored
Jan 18, 2013
by
Ferhat Mihoubi
Browse files
Options
Downloads
Patches
Plain Diff
Correction of a bug in controlled exogenous variables indexation
parent
607210dc
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
matlab/det_cond_forecast.m
+20
-15
20 additions, 15 deletions
matlab/det_cond_forecast.m
with
20 additions
and
15 deletions
matlab/det_cond_forecast.m
+
20
−
15
View file @
fb127d01
...
...
@@ -48,7 +48,7 @@ function det_cond_forecast(constrained_paths, constrained_vars, options_cond_fcs
global
options_
oo_
M_
if
~
isfield
(
options_cond_fcst
,
'periods'
)
||
isempty
(
options_cond_fcst
.
periods
)
options_cond_fcst
.
periods
=
6
0
;
options_cond_fcst
.
periods
=
10
0
;
end
maximum_lag
=
M_
.
maximum_lag
;
...
...
@@ -73,12 +73,14 @@ exo_names = M_.exo_names;
controlled_varexo
=
zeros
(
1
,
n_control_exo
);
for
i
=
1
:
nx
for
j
=
1
:
n_control_exo
if
strcmp
(
exo_names
(
i
,:),
options_cond_fcst
.
controlled_varexo
(
j
,:))
if
strcmp
(
deblank
(
exo_names
(
i
,:)
)
,
deblank
(
options_cond_fcst
.
controlled_varexo
(
j
,:))
)
controlled_varexo
(
j
)
=
i
;
end
end
end
%todo check if zero => error message
save_options_initval_file
=
options_
.
initval_file
;
options_
.
initval_file
=
'__'
;
...
...
@@ -272,22 +274,23 @@ else
disp
(
'computation of derivatives w.r. to exogenous shocks'
);
col_count
=
1
;
for
j
=
controlled_varexo
for
j
=
1
:
length
(
controlled_varexo
)
j_pos
=
controlled_varexo
(
j
);
if
constrained_perfect_foresight
(
j
)
for
time
=
time_index_constraint
saved
=
oo_
.
exo_simul
(
time
,
j
);
oo_
.
exo_simul
(
time
,
j
)
=
oo_
.
exo_simul
(
time
,
j
)
+
eps1
;
saved
=
oo_
.
exo_simul
(
time
,
j
_pos
);
oo_
.
exo_simul
(
time
,
j
_pos
)
=
oo_
.
exo_simul
(
time
,
j
_pos
)
+
eps1
;
simul
();
J
(:,
col_count
)
=
(
oo_
.
endo_simul
(
indx_endo
)
-
ys
)
/
eps1
;
oo_
.
exo_simul
(
time
,
j
)
=
saved
;
oo_
.
exo_simul
(
time
,
j
_pos
)
=
saved
;
col_count
=
col_count
+
1
;
end
;
else
saved
=
oo_
.
exo_simul
(
maximum_lag
+
1
,
j
);
oo_
.
exo_simul
(
maximum_lag
+
1
,
j
)
=
oo_
.
exo_simul
(
maximum_lag
+
1
,
j
)
+
eps1
;
saved
=
oo_
.
exo_simul
(
maximum_lag
+
1
,
j
_pos
);
oo_
.
exo_simul
(
maximum_lag
+
1
,
j
_pos
)
=
oo_
.
exo_simul
(
maximum_lag
+
1
,
j
_pos
)
+
eps1
;
simul
();
J
(:,
col_count
)
=
(
oo_
.
endo_simul
(
indx_endo
)
-
ys
)
/
eps1
;
oo_
.
exo_simul
(
maximum_lag
+
1
,
j
)
=
saved
;
oo_
.
exo_simul
(
maximum_lag
+
1
,
j
_pos
)
=
saved
;
col_count
=
col_count
+
1
;
end
;
end
;
...
...
@@ -304,12 +307,13 @@ else
D_exo
=
-
J
\
r
;
old_exo
=
oo_
.
exo_simul
;
col_count
=
1
;
for
j
=
controlled_varexo
for
j
=
1
:
length
(
controlled_varexo
)
j_pos
=
controlled_varexo
(
j
);
if
constrained_perfect_foresight
(
j
)
oo_
.
exo_simul
(
time_index_constraint
,
j
)
=
(
oo_
.
exo_simul
(
time_index_constraint
,
j
)
+
D_exo
(
col_count
:
col_count
+
constrained_periods
-
t
));
oo_
.
exo_simul
(
time_index_constraint
,
j
_pos
)
=
(
oo_
.
exo_simul
(
time_index_constraint
,
j
_pos
)
+
D_exo
(
col_count
:
col_count
+
constrained_periods
-
t
));
col_count
=
col_count
+
constrained_periods
-
t
+
1
;
else
oo_
.
exo_simul
(
maximum_lag
+
1
,
j
)
=
oo_
.
exo_simul
(
maximum_lag
+
1
,
j
)
+
D_exo
(
col_count
);
oo_
.
exo_simul
(
maximum_lag
+
1
,
j
_pos
)
=
oo_
.
exo_simul
(
maximum_lag
+
1
,
j
_pos
)
+
D_exo
(
col_count
);
col_count
=
col_count
+
1
;
end
;
end
;
...
...
@@ -319,16 +323,17 @@ else
if
~
convg
error
([
'convergence not achived at time '
int2str
(
t
)
' after '
int2str
(
it
)
' iterations'
]);
end
;
for
j
=
controlled_varexo
for
j
=
1
:
length
(
controlled_varexo
)
j_pos
=
controlled_varexo
(
j
);
if
constrained_perfect_foresight
(
j
)
% in case of mixed surprise and perfect foresight
% endogenous path at each date all the exogenous paths have to be
% stored. The paths are stacked in exo.
for
time
=
time_index_constraint
;
exo
(
past_val
+
time
,
j
)
=
oo_
.
exo_simul
(
time
,
j
);
exo
(
past_val
+
time
,
j
_pos
)
=
oo_
.
exo_simul
(
time
,
j
_pos
);
end
else
exo
(
maximum_lag
+
t
,
j
)
=
oo_
.
exo_simul
(
maximum_lag
+
1
,
j
);
exo
(
maximum_lag
+
t
,
j
_pos
)
=
oo_
.
exo_simul
(
maximum_lag
+
1
,
j
_pos
);
end
;
end
;
past_val
=
past_val
+
length
(
time_index_constraint
);
...
...
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