taking nth last observations from a series

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

Fregensburg
Posts: 38
Joined: Tue Jan 21, 2014 4:04 am

taking nth last observations from a series

Postby Fregensburg » Tue Feb 25, 2014 11:38 am

Hi,

I'm trying to get the 3rd last observation of a series, where my workfile is longer than the span of the data, so it extends to a couple of years of NA values after the last observation.

There might be a more efficient way to get that, but I thought that shortening the sample by by excluding the last three observations, and then using the @otod and @elem functions in this manner:

string last = @otod(@ilast(y))
scalar ylastvalue = @elem(y, last)

would allow me to get the values I want.

Using this line:
smpl @first @last-3

does't help -because @last refers to the workfile, rather than the series for the non NA values, so effectively I just get rid of NA observations.

Maybe this:
Smpl if y <> na

can somehow be combined with:

smpl @first @last-3

So far I haven't been able to combine the two. Any ideas on how to implement this?


An aside related to a different topic I posted about here:
http://forums.eviews.com/viewtopic.php?f=3&t=9605

I realised that what Gareth recommended does not apply to forecasting with the Kalman filter. In that context, one may well use an expression -say, dlog(y)- as a dependent variable, but the forecast line returns forecasted values for dlogy rather than y. Is there anything that can be done, then, to back out the original (undifferenced) values?

thanks ever so much

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: taking nth last observations from a series

Postby EViews Gareth » Tue Feb 25, 2014 12:19 pm

Code: Select all

smpl if y<>na scalar value = @elem(y,@otods(@obssmpl-2))


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest