Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dynare
dynare
Commits
a8107e15
Commit
a8107e15
authored
Feb 10, 2017
by
Marco Ratto
Committed by
Stéphane Adjemian
Mar 17, 2017
Browse files
added new annual aggregation types, for consistent quantity/price aggregations, if required.
parent
cb3362b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
matlab/utilities/dataset/quarterly2annual.m
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
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment