series transformation using @recode
Posted: Mon Sep 30, 2013 4:23 am
Good morning,
I'm currently using Eviews 7.
I've got a quarterly time series, say varX, that I want to transform in the following way :
if first quarter then varX_C=varX
if second quarter then varX_C = mean of qarter 1 and 2
if third quarter then varX_C = mean of qarter 1, 2 and 3
if fourth quarter then varX_C = mean of qarter 1, 2, 3 and 4
Here is what I'v came up with :
series varX_C = @recode( @quarter=1, varX, @recode( @quarter=2,( varX + varX(-1) )/2, _
@recode( @quarter=3,( varX + varX(-1) + varX(-2) )/3, _
( varX + varX(-1) + varX(-2) + varX(-3) )/4) )
)
Even though this formula works fine, I was wondering if there is a more elegant way of computing varX_C ?
Thanks!
I'm currently using Eviews 7.
I've got a quarterly time series, say varX, that I want to transform in the following way :
if first quarter then varX_C=varX
if second quarter then varX_C = mean of qarter 1 and 2
if third quarter then varX_C = mean of qarter 1, 2 and 3
if fourth quarter then varX_C = mean of qarter 1, 2, 3 and 4
Here is what I'v came up with :
series varX_C = @recode( @quarter=1, varX, @recode( @quarter=2,( varX + varX(-1) )/2, _
@recode( @quarter=3,( varX + varX(-1) + varX(-2) )/3, _
( varX + varX(-1) + varX(-2) + varX(-3) )/4) )
)
Even though this formula works fine, I was wondering if there is a more elegant way of computing varX_C ?
Thanks!