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
4b1fd537
Commit
4b1fd537
authored
8 years ago
by
Stéphane Adjemian
Browse files
Options
Downloads
Patches
Plain Diff
Added set_historical_values command.
(cherry picked from commit
e043e92c
)
parent
a1f86b97
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/set_historical_values.m
+85
-0
85 additions, 0 deletions
matlab/set_historical_values.m
with
85 additions
and
0 deletions
matlab/
histval_from_dseri
es.m
→
matlab/
set_historical_valu
es.m
+
85
−
0
View file @
4b1fd537
function
[
endo_histval
,
exo_histval
]
=
histval_from_dseri
es
(
ds
,
initialperiod
,
DynareModel
)
function
set_historical_valu
es
(
ds
,
initialperiod
)
% Builds endo_histval and exo_hsitval from the content of a dseries object.
% Builds endo_histval and exo_hsitval from the content of a dseries object.
%
%
% INPUTS
% INPUTS
% - ds [dseries] Dataset.
% - ds [dseries] Dataset.
% - initialperiod [dates] Initial period of the simulation.
% - initialperiod [dates] Initial period of the simulation.
% - DynareModel [struct] Description of the model (M_ global structure).
%
%
% OUTPUTS
% OUTPUTS
% - endo_histval [double] Vector of lagged values for the endogenous variables.
% - none
% - exo_histval [double] Matrix of lagged values for the exogenous variables.
% Copyright (C) 2017 Dynare Team
% Copyright (C) 2017 Dynare Team
%
%
% This file is part of Dynare.
% This file is part of Dynare.
...
@@ -28,49 +25,60 @@ function [endo_histval, exo_histval] = histval_from_dseries(ds, initialperiod, D
...
@@ -28,49 +25,60 @@ function [endo_histval, exo_histval] = histval_from_dseries(ds, initialperiod, D
% You should have received a copy of the GNU General Public License
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
endo_histval
=
zeros
(
DynareModel
.
endo_nbr
,
DynareModel
.
maximum_endo_lag
);
global
M_
if
ischar
(
ds
)
ds
=
evalin
(
'caller'
,
ds
);
end
if
ischar
(
initialperiod
)
initialperiod
=
eval
(
initialperiod
);
end
% Initialize endo_histval.
M_
.
endo_histval
=
zeros
(
M_
.
endo_nbr
,
M_
.
maximum_endo_lag
);
% Fill endo_histval.
k
=
1
;
k
=
1
;
for
i
=
1
:
DynareModel
.
endo_nbr
for
i
=
1
:
M_
.
endo_nbr
if
i
<=
DynareModel
.
orig_endo_nbr
if
i
<=
M_
.
orig_endo_nbr
if
DynareModel
.
lead_lag_incidence
(
1
,
i
)
>
0
if
M_
.
lead_lag_incidence
(
1
,
i
)
>
0
if
any
(
strcmp
(
deblank
(
DynareModel
.
endo_names
(
i
,:)),
ds
.
name
))
if
any
(
strcmp
(
deblank
(
M_
.
endo_names
(
i
,:)),
ds
.
name
))
endo_histval
(
i
,
DynareModel
.
maximum_endo_lag
)
=
...
M_
.
endo_histval
(
i
,
M_
.
maximum_endo_lag
)
=
...
ds
{
deblank
(
DynareModel
.
endo_names
(
i
,:))}(
initialperiod
-
1
)
.
data
;
ds
{
deblank
(
M_
.
endo_names
(
i
,:))}(
initialperiod
-
1
)
.
data
;
else
else
error
(
sprintf
(
'Can
''
t find %s in dseries'
,
...
error
(
sprintf
(
'Can
''
t find %s in dseries'
,
deblank
(
M_
.
endo_names
(
i
,:))))
deblank
(
DynareModel
.
endo_names
(
i
,:))))
end
end
end
end
else
else
a
=
DynareModel
.
aux_vars
(
k
);
a
=
M_
.
aux_vars
(
k
);
if
a
.
type
==
1
if
a
.
type
==
1
if
any
(
strcmp
(
deblank
(
DynareModel
.
endo_names
(
a
.
orig_index
,:)),
ds
.
name
))
if
any
(
strcmp
(
deblank
(
M_
.
endo_names
(
a
.
orig_index
,:)),
ds
.
name
))
endo_histval
(
i
,
DynareModel
.
maximum_endo_lag
)
=
...
M_
.
endo_histval
(
i
,
M_
.
maximum_endo_lag
)
=
...
ds
{
deblank
(
DynareModel
.
endo_names
(
a
.
orig_index
,:))}(
initialperiod
-
1
+
a
.
orig_lead_lag
)
.
data
;
ds
{
deblank
(
M_
.
endo_names
(
a
.
orig_index
,:))}(
initialperiod
-
1
+
a
.
orig_lead_lag
)
.
data
;
else
else
error
(
sprintf
(
'Can
''
t find %s in dseries'
,
...
error
(
sprintf
(
'Can
''
t find %s in dseries'
,
deblank
(
M_
.
endo_names
(
a
.
orig_index
,:))))
deblank
(
DynareModel
.
endo_names
(
a
.
orig_index
,:))))
end
end
end
end
k
=
k
+
1
;
k
=
k
+
1
;
end
end
end
end
if
nargout
>
1
% If model has lags on exogenous variables, initialize and fill exo_histval
exo_histval
=
zeros
(
DynareModel
.
maximum_exo_lag
,
DynareModel
.
exo_nbr
);
if
M_
.
maximum_exo_lag
exo_list
=
cellstr
(
DynareModel
.
exo_names
);
M_
.
exo_histval
=
zeros
(
M_
.
maximum_exo_lag
,
M_
.
exo_nbr
);
exo_list
=
cellstr
(
M_
.
exo_names
);
available_exo_variables
=
ismember
(
exo_list
,
ds
.
name
);
available_exo_variables
=
ismember
(
exo_list
,
ds
.
name
);
if
any
(
~
available_exo_variables
)
if
any
(
~
available_exo_variables
)
skipline
()
skipline
()
disp
(
'Some exogenous variables are not available in the dseries object.'
)
disp
(
'Some exogenous variables are not available in the dseries object.'
)
disp
(
'
Lagged
value
s
for
these
exogenous ar
e
zero.'
)
disp
(
'
Default
value for
lagged
exogenous
v
ar
iables is
zero.'
)
skipline
()
skipline
()
end
end
for
t
=
1
:
DynareModel
.
maximum_exo_lag
for
t
=
1
:
M_
.
maximum_exo_lag
for
i
=
1
:
DynareModel
.
exo_nbr
for
i
=
1
:
M_
.
exo_nbr
if
available_exo_variables
(
i
)
if
available_exo_variables
(
i
)
exo_histval
(
DynareModel
.
maximum_exo_lag
+
1
-
t
,
i
)
=
ds
{
exo_list
{
i
}}(
initialperiod
-
t
)
.
data
;
exo_histval
(
M_
.
maximum_exo_lag
+
1
-
t
,
i
)
=
ds
{
exo_list
{
i
}}(
initialperiod
-
t
)
.
data
;
end
end
end
end
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