Page 1 of 1

series transformation using @recode

Posted: Mon Sep 30, 2013 4:23 am
by DBel2012
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!

Re: series transformation using @recode

Posted: Mon Sep 30, 2013 9:27 am
by EViews Glenn
There may be a better way, but this should work if your workfile/sample starts in the first quarter.

Code: Select all

series anncumulative = @recode(@quarter=1, y, anncumulative(-1)+y(-1)) series ystar = @meansby(anncumulative, @quarter)
If we had a year-to-date function (we've added it to the list) this would be easier.

Re: series transformation using @recode

Posted: Tue Oct 01, 2013 4:35 am
by DBel2012
I like the code you posted.

Many thanks Glenn!

Re: series transformation using @recode

Posted: Tue Oct 01, 2013 10:04 am
by EViews Glenn
It would be good if I posted correct code.

Code: Select all

series anncumulative = @recode(@quarter=1, y, anncumulative(-1)+y)
The last element on the first line should be Y, not Y(-1).