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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dynare
dynare
Commits
a8107e15
Commit
a8107e15
authored
Feb 10, 2017
by
Marco Ratto
Committed by
Stéphane Adjemian
Mar 17, 2017
Browse files
Options
Downloads
Patches
Plain Diff
added new annual aggregation types, for consistent quantity/price aggregations, if required.
parent
cb3362b8
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/utilities/dataset/quarterly2annual.m
+53
-3
53 additions, 3 deletions
matlab/utilities/dataset/quarterly2annual.m
with
53 additions
and
3 deletions
matlab/utilities/dataset/quarterly2annual.m
+
53
−
3
View file @
a8107e15
function
[
ya
,
yass
,
gya
,
gyass
]
=
quarterly2annual
(
y
,
yss
,
GYTREND0
,
type
,
islog
)
% function [ya, yass, gya, gyass] = quarterly2annual(y,yss,GYTREND0,type,islog)
function
[
ya
,
yass
,
gya
,
gyass
]
=
quarterly2annual
(
y
,
yss
,
GYTREND0
,
type
,
islog
,
aux
)
% function [ya, yass, gya, gyass] = quarterly2annual(y,yss,GYTREND0,type,islog
,aux
)
% transforms quarterly (log-)level time series to annual level and growth rate
% it accounts for stock/flow/deflator series.
%
...
...
@@ -11,8 +11,13 @@ function [ya, yass, gya, gyass] = quarterly2annual(y,yss,GYTREND0,type,islog)
% 2 average
% 3 last period (Q4)
% 4 geometric average
% 5 annual price as quantity weighted average
% 6 annual quantity from average price
% 7 annual nominal from Q real and deflator
% islog 0 level (default)
% 1 log-level
% aux optional input used when type>4
%
%
% OUTPUTS
% ya annual (log-)level
...
...
@@ -48,30 +53,75 @@ end
if
nargin
<
5
||
isempty
(
islog
),
islog
=
0
;
end
if
isstruct
(
aux
),
yaux
=
aux
.
y
;
yauxss
=
aux
.
yss
;
islogaux
=
aux
.
islog
;
GYTREND0aux
=
aux
.
GYTREND0
;
typeaux
=
aux
.
type
;
if
islogaux
yaux
=
exp
(
yaux
+
yauxss
);
yauxss
=
exp
(
yauxss
);
yaux
=
yaux
-
yauxss
;
end
elseif
type
>
4
,
error
(
'TYPE>4 requires auxiliary variable!'
)
end
if
islog
y
=
exp
(
y
+
yss
);
yss
=
exp
(
yss
);
y
=
y
-
yss
;
end
switch
type
case
1
yass
=
yss
*
(
exp
(
-
GYTREND0
*
3
)
+
exp
(
-
GYTREND0
*
2
)
+
exp
(
-
GYTREND0
)
+
1
);
tmp
=
lagged
(
y
,
3
)
*
exp
(
-
GYTREND0
*
3
)
+
lagged
(
y
,
2
)
*
exp
(
-
GYTREND0
*
2
)
+
lagged
(
y
,
1
)
*
exp
(
-
GYTREND0
)
+
y
;
% annualized level
ya
=
tmp
(
4
:
4
:
end
);
case
2
yass
=
yss
*
(
exp
(
-
GYTREND0
*
3
)
+
exp
(
-
GYTREND0
*
2
)
+
exp
(
-
GYTREND0
)
+
1
)/
4
;
tmp
=
(
lagged
(
y
,
3
)
*
exp
(
-
GYTREND0
*
3
)
+
lagged
(
y
,
2
)
*
exp
(
-
GYTREND0
*
2
)
+
lagged
(
y
,
1
)
*
exp
(
-
GYTREND0
)
+
y
)/
4
;
% annualized level
ya
=
tmp
(
4
:
4
:
end
);
case
3
yass
=
yss
;
tmp
=
y
;
ya
=
tmp
(
4
:
4
:
end
);
case
4
yass
=
yss
*
(
exp
(
-
GYTREND0
*
3
/
2
));
tmp
=
(
lagged
(
y
+
yss
,
3
)
*
exp
(
-
GYTREND0
*
3
)
.*
lagged
(
y
+
yss
,
2
)
*
exp
(
-
GYTREND0
*
2
)
.*
lagged
(
y
+
yss
,
1
)
*
exp
(
-
GYTREND0
)
.*
(
y
+
yss
))
.^
(
1
/
4
);
% annualized level
tmp
=
tmp
-
yass
;
ya
=
tmp
(
4
:
4
:
end
);
case
5
% nominal series
[
yna
,
ynass
]
=
quarterly2annual
(
y
.*
yaux
,
yss
.*
yauxss
,
GYTREND0
+
GYTREND0aux
,
typeaux
,
0
,
0
);
% real series
[
yra
,
yrass
]
=
quarterly2annual
(
yaux
,
yauxss
,
GYTREND0aux
,
typeaux
,
0
,
0
);
% deflator
yass
=
ynass
/
yrass
;
ya
=
yna
.
/
yra
;
case
6
% nominal series
[
yna
,
ynass
]
=
quarterly2annual
(
y
.*
yaux
,
yss
.*
yauxss
,
GYTREND0
+
GYTREND0aux
,
typeaux
,
0
,
0
);
% deflator
[
pa
,
pass
]
=
quarterly2annual
(
yaux
,
yauxss
,
GYTREND0aux
,
2
,
0
,
0
);
% real series
yass
=
ynass
/
pass
;
ya
=
yna
.
/
pa
;
case
7
% nominal series
[
ya
,
yass
]
=
quarterly2annual
(
y
.*
yaux
,
yss
.*
yauxss
,
GYTREND0
+
GYTREND0aux
,
typeaux
,
0
,
0
);
GYTREND0
=
GYTREND0
+
GYTREND0aux
;
otherwise
error
(
'Wrong type input'
)
end
ya
=
tmp
(
4
:
4
:
end
);
% annual growth rate
gyass
=
GYTREND0
*
4
;
gya
=
(
ya
+
yass
)
.
/(
lagged
(
ya
,
1
)
+
yass
)
.*
exp
(
4
*
GYTREND0
)
-
1
-
gyass
;
...
...
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