Page 1 of 1

Interpolation of first/last point in sample

Posted: Tue Apr 13, 2010 9:16 am
by javiersan
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

Re: Interpolation of first/last point in sample

Posted: Tue Apr 13, 2010 9:50 am
by EViews Gareth
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

Re: Interpolation of first/last point in sample

Posted: Tue Apr 13, 2010 10:12 am
by javiersan
Thanks a lot. I didn't remember that @trend created the index.

Regards,

Javier