Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dseries
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Johannes Pfeifer
dseries
Commits
de0967a4
Verified
Commit
de0967a4
authored
2 years ago
by
Stéphane Adjemian
Browse files
Options
Downloads
Patches
Plain Diff
Add new function.
dummy variable in a dseries object.
parent
43f6865e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/utilities/misc/dummy.m
+101
-0
101 additions, 0 deletions
src/utilities/misc/dummy.m
with
101 additions
and
0 deletions
src/utilities/misc/dummy.m
0 → 100644
+
101
−
0
View file @
de0967a4
function
o
=
dummy
(
iperiod
,
len
,
subperiod
,
name
)
% --*-- Unitary tests --*--
% Returns a dummy in a dseries object.
%
% INPUTS
% - iperiod [dates] scalar, initial period.
% - len [integer] scalar, number of periods.
% - superiod [integer] scalar or vector, subperiod(s) index where the dummy is nonzero.
% - name [char] row char array, name of the dummy variable.
%
% OUTPUTS
% - o [dseries]
% Copyright © 2022 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 <https://www.gnu.org/licenses/>.
if
~
(
isdate
(
iperiod
)
||
isdates
(
iperiod
))
error
(
'First input argument must be a string date or dates object.'
)
end
if
~
(
isscalar
(
len
)
&&
isint
(
len
))
error
(
'Second input argument must be a scalar integer.'
)
end
if
~
((
isscalar
(
subperiod
)
||
isvector
(
subperiod
))
&&
all
(
isint
(
subperiod
)))
error
(
'Second input argument must be a scalar integer.'
)
else
if
~
issubperiod
(
subperiod
,
dates
(
iperiod
)
.
freq
)
error
(
'Third input argument is not a subperiod.'
)
end
end
p
=
dates
(
iperiod
)
+
(
0
:
len
-
1
);
d
=
zeros
(
len
,
1
);
for
i
=
1
:
length
(
subperiod
)
d
(
p
.
subperiod
()
==
subperiod
(
i
))
=
1
;
end
o
=
dseries
(
d
,
iperiod
,
name
);
return
%@test:1
try
ts
=
dummy
(
dates
(
'1950Q1'
),
15
,
2
,
'toto'
);
t
(
1
)
=
true
;
catch
t
(
1
)
=
false
;
end
if
t
(
1
)
t
(
2
)
=
all
(
ts
(
ts
.
dates
.
subperiod
()
==
2
)
.
data
);
end
T
=
all
(
t
);
%@eof:1
%@test:2
try
ts
=
dummy
(
'1950Q1'
,
15
,
2
,
'toto'
);
t
(
1
)
=
true
;
catch
t
(
1
)
=
false
;
end
if
t
(
1
)
t
(
2
)
=
all
(
ts
(
ts
.
dates
.
subperiod
()
==
2
)
.
data
);
end
T
=
all
(
t
);
%@eof:2
%@test:3
try
ts
=
dummy
(
'1950Q1'
,
15
,
[
1
,
2
,
3
,
4
],
'toto'
);
t
(
1
)
=
true
;
catch
t
(
1
)
=
false
;
end
if
t
(
1
)
t
(
2
)
=
all
(
ts
.
data
);
end
T
=
all
(
t
);
%@eof:3
\ 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