Cublic Spline
Cublic Spline
Does anyone know if it is possible to use cubic spline data interpolation in RATS?
Re: Cublic Spline
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 general idea below. For a specific example of this applied to bond yields, see http://www.estima.com/forum/viewtopic.php?f=8&t=2150.e1983 wrote:Does anyone know if it is possible to use cubic spline data interpolation in RATS?
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