Page 1 of 1

"Dynamic" YTD

Posted: Wed May 22, 2019 3:33 pm
Hi,

I'm new to Eviews (currently using version 10) so I'll try my best to explain what my issue is; I'm trying to create a piece of code to give me a year-to-date (YTD) value for monthly series (which is different from the @YTD that already exists). In this instance year YTD is taking the average of the monthly observations so far in 2019 divided by the same months average for 2018.

I.e., if we have housing starts (hssa in the code below) till April 2019, the YTD would be
(average 2019m1-2019m4) / (average 2018m1-2018m4). When data for May 2019 comes out the formula should change to (average 2019m1-2019m5) / (average 2018m1-2018m5).

In my code below I get an error message for the "@last(-12)" saying "Error in Sample: Illegal date @LAST(.". I'm trying to create the average value for 2018 by lagging the most recent observation (2019m4) by 12 to get 2018m4

genr hssa_ytd = (@mean(hssa, "2019m1 @last"))/(@mean(hssa, "2018m1 @last(-12)")

Has anyone come across a similar issue and are willing to share their solution?

Any input is greatly appreciated!

Thank you so much,
Joachim

Re: "Dynamic" YTD

Posted: Wed May 22, 2019 3:50 pm
The error in your specific code can be rectified, I think, by removing the () around the -12. Samples don't use () for lags.

As you mention, there is a @YTD function in EViews 11 that gives the year-to-date sum. To calculate the year-to-date average, you could call @ytd with a series of 1:

Code: Select all

`series av_ytd = @ytd(hssa)/@ytd(1)`

To get the ratio of this year's ytd compared with last years, you'd do a simple division:

Code: Select all

`series av_ytd_diff = (@ytd(hssa)/@ytd(1)) / (@ytd(hssa(-12))/@ytd(1))`

But of course this is silly because the @ytd(1) would cancel so you just need:

Code: Select all

`series av_ytd_diff = @ytd(hssa)/@ytd(hssa(-12))`

Re: "Dynamic" YTD

Posted: Thu May 23, 2019 9:37 am
Thank you for the response Gareth, I'll look into your suggestions and let you know how it goes.

Joachim