Interpolation of first/last point in sample

For questions regarding programming in the EViews programming language.

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

javiersan
Posts: 184
Joined: Mon Jan 19, 2009 8:18 am

Interpolation of first/last point in sample

Postby javiersan » Tue Apr 13, 2010 9:16 am

Hi,

I have a series x and, say, 4 sample periods. I want to create a series y that is the linear interpolation of the beginning and end-points of the samples.

Code: Select all

sample s1 1980 1990 sample s2 1990 1998 sample s3 1998 2002 sample s4 2002 2009 for !ss=1 to 4 smpl s{!ss} series temp=@recode([if index=1 or last],x,na) y.ipolate temp delete temp next !ss
The code above shows roughly the idea but I don't know 1) how to combine @recode with an "index" that goes from 1 to the total sample observations, or whether this is possible; 2) if y will contain the four "lines" (or if every time y.ipolate is used it creates a new series - and fills with NAs everything outside of the sample period).

Could you please help?

Thanks,

Javier

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

Re: Interpolation of first/last point in sample

Postby EViews Gareth » Tue Apr 13, 2010 9:50 am

There's probably an easier way than this, but I think this works:

Code: Select all

sample s1 1980 1990 sample s2 1990 1998 sample s3 1998 2002 sample s4 2002 2009 series ypolate for !ss=1 to 4 smpl s{!ss} series trend=@trend series temp = @recode(trend=@min(trend) or trend=@max(trend), y, na) temp.ipolate(f=na) temp2 ypolate=temp2 next smpl @all

javiersan
Posts: 184
Joined: Mon Jan 19, 2009 8:18 am

Re: Interpolation of first/last point in sample

Postby javiersan » Tue Apr 13, 2010 10:12 am

Thanks a lot. I didn't remember that @trend created the index.

Regards,

Javier


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests