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
744f3fd4
Commit
744f3fd4
authored
13 years ago
by
Stéphane Adjemian
Browse files
Options
Downloads
Patches
Plain Diff
Added Stochastic Extended Path method (SEP).
parent
7ff36b68
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
matlab/ep/extended_path.m
+132
-123
132 additions, 123 deletions
matlab/ep/extended_path.m
with
132 additions
and
123 deletions
matlab/ep/extended_path.m
+
132
−
123
View file @
744f3fd4
...
@@ -79,7 +79,7 @@ make_ex_;
...
@@ -79,7 +79,7 @@ make_ex_;
make_y_
;
make_y_
;
% Initialize the output array.
% Initialize the output array.
time_series
=
NaN
(
M_
.
endo_nbr
,
sample_size
+
1
);
time_series
=
zeros
(
M_
.
endo_nbr
,
sample_size
);
% Set the covariance matrix of the structural innovations.
% Set the covariance matrix of the structural innovations.
variances
=
diag
(
M_
.
Sigma_e
);
variances
=
diag
(
M_
.
Sigma_e
);
...
@@ -106,6 +106,7 @@ if options_.ep.stochastic
...
@@ -106,6 +106,7 @@ if options_.ep.stochastic
[
r
,
w
]
=
gauss_hermite_weights_and_nodes
(
options_
.
ep
.
number_of_nodes
);
[
r
,
w
]
=
gauss_hermite_weights_and_nodes
(
options_
.
ep
.
number_of_nodes
);
switch
options_
.
ep
.
stochastic
switch
options_
.
ep
.
stochastic
case
1
case
1
if
M_
.
exo_nbr
>
1
rr
=
cell
(
1
);
rr
=
cell
(
1
);
ww
=
cell
(
1
);
ww
=
cell
(
1
);
for
i
=
1
:
size
(
M_
.
Sigma_e
,
1
)
for
i
=
1
:
size
(
M_
.
Sigma_e
,
1
)
...
@@ -114,10 +115,19 @@ if options_.ep.stochastic
...
@@ -114,10 +115,19 @@ if options_.ep.stochastic
end
end
rrr
=
cartesian_product_of_sets
(
rr
{:});
rrr
=
cartesian_product_of_sets
(
rr
{:});
www
=
cartesian_product_of_sets
(
ww
{:});
www
=
cartesian_product_of_sets
(
ww
{:});
else
rrr
=
r
;
www
=
w
;
end
www
=
prod
(
www
,
2
);
www
=
prod
(
www
,
2
);
nnn
=
length
(
www
);
otherwise
otherwise
error
([
'Order '
int2str
(
options_
.
ep
.
stochastic
)
' Stochastic Extended Path method is not implemented!'
])
error
([
'Order '
int2str
(
options_
.
ep
.
stochastic
)
' Stochastic Extended Path method is not implemented!'
])
end
end
else
rrr
=
zeros
(
1
,
number_of_structural_innovations
);
www
=
1
;
nnn
=
1
;
end
end
% Initializes some variables.
% Initializes some variables.
...
@@ -158,7 +168,9 @@ while (t<sample_size)
...
@@ -158,7 +168,9 @@ while (t<sample_size)
shocks
=
oo_
.
ep
.
shocks
(
t
,:);
shocks
=
oo_
.
ep
.
shocks
(
t
,:);
% Put it in oo_.exo_simul (second line).
% Put it in oo_.exo_simul (second line).
oo_
.
exo_simul
(
2
,
positive_var_indx
)
=
shocks
;
oo_
.
exo_simul
(
2
,
positive_var_indx
)
=
shocks
;
if
options_
.
ep
.
init
&&
t
==
1
% Compute first order solution.
for
s
=
1
:
nnn
oo_
.
exo_simul
(
3
,
positive_var_indx
)
=
rrr
(
s
,:)
*
covariance_matrix_upper_cholesky
;
if
options_
.
ep
.
init
&&
s
==
1
% Compute first order solution. t==1 &&
initial_path
=
simult_
(
initial_conditions
,
oo_
.
dr
,
oo_
.
exo_simul
(
2
:
end
,:),
1
);
initial_path
=
simult_
(
initial_conditions
,
oo_
.
dr
,
oo_
.
exo_simul
(
2
:
end
,:),
1
);
if
options_
.
ep
.
init
==
1
if
options_
.
ep
.
init
==
1
oo_
.
endo_simul
(:,
1
:
end
-
1
)
=
initial_path
(:,
1
:
end
-
1
);
% Last column is the steady state.
oo_
.
endo_simul
(:,
1
:
end
-
1
)
=
initial_path
(:,
1
:
end
-
1
);
% Last column is the steady state.
...
@@ -278,20 +290,15 @@ while (t<sample_size)
...
@@ -278,20 +290,15 @@ while (t<sample_size)
else
else
oo_
.
endo_simul
=
tmp
;
oo_
.
endo_simul
=
tmp
;
end
end
if
nargin
==
6
zlb_periods
=
find
(
oo_
.
endo_simul
(
zlb_idx
,:)
<=
1
+
1e-12
);
zlb_number_of_periods
=
length
(
zlb_periods
);
if
zlb_number_of_periods
count_zlb
=
[
count_zlb
;
[
t
,
zlb_number_of_periods
,
zlb_periods
(
1
)
,
zlb_periods
(
end
)]
];
end
end
% Save results of the perfect foresight model solver.
% Save results of the perfect foresight model solver.
time_series
(:,
t
)
=
oo_
.
endo_simul
(:,
2
);
time_series
(:,
t
)
=
time_series
(:,
t
)
+
www
(
s
)
*
oo_
.
endo_simul
(:,
2
);
save
(
'simulated_paths.mat'
,
'time_series'
);
%
save('simulated_paths.mat','time_series');
% Set initial condition for the nex round.
% Set initial condition for the nex round.
%initial_conditions = oo_.endo_simul(:,2);
%initial_conditions = oo_.endo_simul(:,2);
oo_
.
endo_simul
=
oo_
.
endo_simul
(:,
1
:
options_
.
periods
+
2
);
end
%oo_.endo_simul = oo_.endo_simul(:,1:options_.periods+M_.maximum_endo_lag+M_.maximum_endo_lead);
oo_
.
endo_simul
(:,
1
:
end
-
1
)
=
oo_
.
endo_simul
(:,
2
:
end
);
oo_
.
endo_simul
(:,
1
:
end
-
1
)
=
oo_
.
endo_simul
(:,
2
:
end
);
oo_
.
endo_simul
(:,
1
)
=
time_series
(:,
t
);
oo_
.
endo_simul
(:,
end
)
=
oo_
.
steady_state
;
oo_
.
endo_simul
(:,
end
)
=
oo_
.
steady_state
;
end
end
...
@@ -302,3 +309,5 @@ else
...
@@ -302,3 +309,5 @@ else
fprintf
(
back
);
fprintf
(
back
);
end
end
end
end
oo_
.
endo_simul
=
oo_
.
steady_state
;
\ No newline at end of file
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