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
Selma Malmberg
dynare
Commits
c09d45c4
Commit
c09d45c4
authored
11 years ago
by
Sébastien Villemot
Browse files
Options
Downloads
Patches
Plain Diff
New smoother2histval function.
Ref #594
parent
c58183b5
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
+95
-0
95 additions, 0 deletions
matlab/smoother2histval.m
with
95 additions
and
0 deletions
matlab/smoother2histval.m
0 → 100644
+
95
−
0
View file @
c09d45c4
function
smoother2histval
(
file
,
period
,
invars
,
outvars
)
% This function takes values from oo_.SmoothedVariables and copies them into
% M_.histval.
%
% INPUTS
% file: An optional *_results MAT file created by Dynare.
% If present, oo_.SmoothedVariables is read from there.
% Otherwise, it is read from the global workspace.
% period: An optional period number to use as the starting point
% for subsequent simulations. It should be between 1 and
% the number of observations that were used to produce the
% smoothed values. If absent, the last observation is used.
% invars: An optional cell array listing variables to read in
% oo_.SmoothedVariables. If absent, all the endogenous
% variables of the current model are used (from M_.endo_names)
% outvars: An optional cell array listing variables to be written in
% M_.histval. This cell must be of same length than invars,
% and there is a mapping between the input variable at the
% i-th position in invars, and the output variable at the
% i-th position in outvars. If absent, then taken as equal
% to invars.
% Copyright (C) 2014 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global
M_
options_
oo_
if
nargin
==
0
if
~
isfield
(
oo_
,
'SmoothedVariables'
)
error
(
'Could not find smoothed variables; did you set the "smoother" option?'
)
end
smoothedvals
=
oo_
.
SmoothedVariables
;
else
S
=
load
(
file
);
if
~
isfield
(
S
,
'oo_'
)
||
~
isfield
(
S
.
oo_
,
'SmoothedVariables'
)
error
(
'Could not find smoothed variables in file; is this a Dynare results file, and did you set the "smoother" option when producing it?'
)
end
smoothedvals
=
S
.
oo_
.
SmoothedVariables
;
end
n
=
size
(
getfield
(
smoothedvals
,
fieldnames
(
smoothedvals
){
1
}));
if
n
<
M_
.
maximum_endo_lag
error
(
'Not enough observations to create initial conditions'
)
end
if
nargin
<
2
period
=
n
;
else
if
period
>
n
error
(
'The period that you indicated is beyond the data sample'
)
end
if
period
<
M_
.
maximum_endo_lag
error
(
'The period that you indicated is too small to construct initial conditions'
)
end
end
if
nargin
<
3
invars
=
cellstr
(
M_
.
endo_names
);
end
if
nargin
<
4
outvars
=
invars
;
else
if
length
(
invars
)
~=
length
(
outvars
)
error
(
'The number of input and output variables is not the same'
)
end
end
M_
.
endo_histval
=
repmat
(
oo_
.
steady_state
,
1
,
M_
.
maximum_endo_lag
);
for
i
=
1
:
length
(
invars
)
s
=
getfield
(
smoothedvals
,
invars
{
i
});
j
=
strmatch
(
outvars
{
i
},
M_
.
endo_names
,
'exact'
);
if
isempty
(
j
)
error
([
'Ouput variable '
outvars
{
i
}
' does not exist'
])
end
M_
.
endo_histval
(
j
,
:)
=
s
((
period
-
M_
.
maximum_endo_lag
+
1
):
period
);
end
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