Cublic Spline

Econometrics questions and discussions

Cublic Spline

Postby e1983 » Mon Aug 29, 2011 2:58 pm

Does anyone know if it is possible to use cubic spline data interpolation in RATS?
e1983
 
Posts: 5
Joined: Sun Aug 28, 2011 2:32 am

Re: Cublic Spline

Postby TomDoan » Mon Aug 29, 2011 5:26 pm

e1983 wrote:Does anyone know if it is possible to use cubic spline data interpolation in RATS?


The Durbin and Koopman examples DURKP136.RPF and DURKP172.RPF do cubic splines. Both of those have "knots" at every observation. For fewer knots, you can use the following:

Code: Select all
compute nk = 3           ;* number of spline knots

*** Compute Break Points
declare vector[integer] nks(nk+1)
 compute nks(1) = 1
 do i = 1, nk
  compute frac = (float(i))/(float(nk+1))
  compute nks(i+1) = fix(frac*(float(nlast-nfirst+1)))
 end do i
declare vector[series] splreg(nk+4)
set splreg(1) = 1.
set splreg(2) = (t-nfirst+1)
set splreg(3) = (t-nfirst+1)*(t-nfirst+1)

do ik = 1,nk+1
 set t1 = splreg(2)(t) - nks(ik)
 set splreg(ik+3) = 0.5*t1(t)*t1(t)*t1(t)
 set splreg(ik+3) = splreg(ik+3)*(splreg(2)(t)>nks(ik))
end do ik

*** Detrend series using cubic splines: USER CHOOSES HERE
linreg(noprint) y / yr
# splreg(1) to splreg(nk+4)
linreg(noprint) rl_rs / rlrs
# splreg(1) to splreg(nk+4)
set y = yr
set rl = rlrs + rs
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Cublic Spline

Postby e1983 » Fri Sep 23, 2011 3:14 am

Thanks so much Tom. Do you know of any examples in RATS that uses cubic splines to interpolate a yield curve?
e1983
 
Posts: 5
Joined: Sun Aug 28, 2011 2:32 am

Re: Cublic Spline

Postby TomDoan » Fri Sep 23, 2011 12:13 pm

This does a cubic spline approximation to the discount function, as described in McCulloch(1971), "Measuring the Term Structure of Interest Rates", Journal of Business, vol 44, pp 19-31.

bondspline.rpf
Program file
(2.64 KiB) Downloaded 91 times

bonds.xls
Data file
(31.5 KiB) Downloaded 85 times
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Cublic Spline

Postby e1983 » Mon Sep 26, 2011 4:49 pm

thanks Tom.
e1983
 
Posts: 5
Joined: Sun Aug 28, 2011 2:32 am


Return to General Econometrics

Who is online

Users browsing this forum: No registered users and 1 guest