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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Stéphane Adjemian
dynare
Commits
c050e306
Verified
Commit
c050e306
authored
Sep 17, 2021
by
Johannes Pfeifer
Committed by
Sébastien Villemot
Sep 17, 2021
Browse files
Options
Downloads
Patches
Plain Diff
smoother2histval.m: fix initialization and dimensions
Closes
Dynare/dynare#1775
(cherry picked from commit
489e6684
)
parent
afeddc66
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
matlab/smoother2histval.m
+18
-16
18 additions, 16 deletions
matlab/smoother2histval.m
with
18 additions
and
16 deletions
matlab/smoother2histval.m
+
18
−
16
View file @
c050e306
...
@@ -24,7 +24,7 @@ function smoother2histval(opts)
...
@@ -24,7 +24,7 @@ function smoother2histval(opts)
%
%
% The function also uses the value of option_.parameter_set
% The function also uses the value of option_.parameter_set
% Copyright (C) 2014-201
8
Dynare Team
% Copyright (C) 2014-20
2
1 Dynare Team
%
%
% This file is part of Dynare.
% This file is part of Dynare.
%
%
...
@@ -49,7 +49,6 @@ if ~isfield(opts, 'infile')
...
@@ -49,7 +49,6 @@ if ~isfield(opts, 'infile')
end
end
smoothedvars
=
oo_
.
SmoothedVariables
;
smoothedvars
=
oo_
.
SmoothedVariables
;
smoothedshocks
=
oo_
.
SmoothedShocks
;
smoothedshocks
=
oo_
.
SmoothedShocks
;
steady_state
=
oo_
.
steady_state
;
else
else
S
=
load
(
opts
.
infile
);
S
=
load
(
opts
.
infile
);
if
~
isfield
(
S
,
'oo_'
)
||
~
isfield
(
S
.
oo_
,
'SmoothedVariables'
)
if
~
isfield
(
S
,
'oo_'
)
||
~
isfield
(
S
.
oo_
,
'SmoothedVariables'
)
...
@@ -57,7 +56,6 @@ else
...
@@ -57,7 +56,6 @@ else
end
end
smoothedvars
=
S
.
oo_
.
SmoothedVariables
;
smoothedvars
=
S
.
oo_
.
SmoothedVariables
;
smoothedshocks
=
S
.
oo_
.
SmoothedShocks
;
smoothedshocks
=
S
.
oo_
.
SmoothedShocks
;
steady_state
=
S
.
oo_
.
steady_state
;
end
end
% Hack to determine if oo_.SmoothedVariables was computed after a Metropolis
% Hack to determine if oo_.SmoothedVariables was computed after a Metropolis
...
@@ -81,7 +79,7 @@ if post_metropolis
...
@@ -81,7 +79,7 @@ if post_metropolis
if
length
(
tmp
)
~=
M_
.
endo_nbr
if
length
(
tmp
)
~=
M_
.
endo_nbr
warning
([
'You are using smoother2histval although smoothed values have not '
...
warning
([
'You are using smoother2histval although smoothed values have not '
...
'been computed for all endogenous and auxiliary variables.'
...
'been computed for all endogenous and auxiliary variables.'
...
'The value of these variables will be set to
0
.'
])
'The value of these variables will be set to
their steady state
.'
])
end
end
tmpexo
=
fieldnames
(
smoothedshocks
.
Mean
);
tmpexo
=
fieldnames
(
smoothedshocks
.
Mean
);
else
else
...
@@ -94,7 +92,6 @@ if isempty(options_.parameter_set)
...
@@ -94,7 +92,6 @@ if isempty(options_.parameter_set)
if
post_metropolis
if
post_metropolis
smoothedvars
=
smoothedvars
.
Mean
;
smoothedvars
=
smoothedvars
.
Mean
;
smoothedshocks
=
smoothedshocks
.
Mean
;
smoothedshocks
=
smoothedshocks
.
Mean
;
steady_state
=
zeros
(
size
(
steady_state
));
end
end
else
else
switch
options_
.
parameter_set
switch
options_
.
parameter_set
...
@@ -112,14 +109,12 @@ else
...
@@ -112,14 +109,12 @@ else
end
end
smoothedvars
=
smoothedvars
.
Mean
;
smoothedvars
=
smoothedvars
.
Mean
;
smoothedshocks
=
smoothedshocks
.
Mean
;
smoothedshocks
=
smoothedshocks
.
Mean
;
steady_state
=
zeros
(
size
(
steady_state
));
case
'posterior_median'
case
'posterior_median'
if
~
post_metropolis
if
~
post_metropolis
error
(
'Option parameter_set=posterior_median is not consistent with computed smoothed values.'
)
error
(
'Option parameter_set=posterior_median is not consistent with computed smoothed values.'
)
end
end
smoothedvars
=
smoothedvars
.
Median
;
smoothedvars
=
smoothedvars
.
Median
;
smoothedshocks
=
smoothedshocks
.
Median
;
smoothedshocks
=
smoothedshocks
.
Median
;
steady_state
=
zeros
(
size
(
steady_state
));
otherwise
otherwise
error
([
'Option parameter_set='
options_
.
parameter_set
' unsupported.'
])
error
([
'Option parameter_set='
options_
.
parameter_set
' unsupported.'
])
end
end
...
@@ -171,20 +166,27 @@ if ~isfield(opts, 'outfile')
...
@@ -171,20 +166,27 @@ if ~isfield(opts, 'outfile')
M_
.
endo_histval
=
repmat
(
oo_
.
steady_state
,
1
,
M_
.
maximum_lag
);
M_
.
endo_histval
=
repmat
(
oo_
.
steady_state
,
1
,
M_
.
maximum_lag
);
else
else
% Output to a file
% Output to a file
data
=
zeros
(
M_
.
maximum_endo_lag
,
length
(
invars
));
for
i
=
1
:
length
(
outvars
)
j
=
strmatch
(
outvars
{
i
},
M_
.
endo_names
,
'exact'
);
if
~
isempty
(
j
)
data
(:,
i
)
=
oo_
.
steady_state
(
j
);
end
end
o
=
dseries
();
o
=
dseries
();
end
end
% Handle all endogenous variables to be copied
% Handle all endogenous variables to be copied
data
=
zeros
(
M_
.
orig_maximum_endo_lag
,
length
(
invars
));
k
=
M_
.
orig_maximum_endo_lag
-
M_
.
maximum_endo_lag
+
1
:
M_
.
orig_maximum_lag
;
for
i
=
1
:
length
(
invars
)
for
i
=
1
:
length
(
invars
)
if
isempty
(
strmatch
(
invars
{
i
},
M_
.
endo_names
,
'exact'
))
if
~
isempty
(
strmatch
(
invars
{
i
},
M_
.
endo_names
,
'exact'
))
% Skip exogenous
continue
end
s
=
smoothedvars
.
(
invars
{
i
});
s
=
smoothedvars
.
(
invars
{
i
});
j
=
strmatch
(
invars
{
i
},
M_
.
endo_names
,
'exact'
);
elseif
~
isempty
(
strmatch
(
invars
{
i
},
M_
.
exo_names
,
'exact'
))
v
=
s
((
period
-
M_
.
orig_maximum_endo_lag
+
1
):
period
);
% + steady_state(j);
s
=
smoothedshocks
.
(
invars
{
i
});
else
error
(
'smoother2histval: unknown input variable'
)
end
v
=
s
((
period
-
M_
.
maximum_lag
+
1
):
period
);
if
~
isfield
(
opts
,
'outfile'
)
if
~
isfield
(
opts
,
'outfile'
)
j
=
strmatch
(
outvars
{
i
},
M_
.
endo_names
,
'exact'
);
j
=
strmatch
(
outvars
{
i
},
M_
.
endo_names
,
'exact'
);
if
isempty
(
j
)
if
isempty
(
j
)
...
...
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