Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

splinefun with method='fmm'

Tags:

r

spline

I've unsuccessfully searched the Internet for an hour now and cannot, for the life of me, find an explanation of how exactly splinefun fits a spline to a set of points when using method='fmm' (the method due to Forsythe, Malcolm and Moler). I know the following:

Fitting a cubic spline with N knots is a problem with (N-1)*4 unknowns. You get (N-1)*2 equations from assuming that the spline goes through all knots and (N-2)*2 conditions by assuming that the spline is smooth at the knots (precisely: that its first and second derivatives are continuous). That leaves 2 conditions to pin down the spline. A natural cubic is found by assuming that the second derivatives are zero at the endpoints. But fmm does something different. As far as I can make out it fits an exact cubic to a subset of knots (which knots?) and then imposes certain derivatives of this cubic on the spline (which derivatives evaluated where?).

like image 365
RoyalTS Avatar asked Mar 19 '14 14:03

RoyalTS


1 Answers

As you have pointed out correctly, two more conditions are required to fully define the spline. In the R documentation for splinefun, the following book is referenced:

Forsythe, G. E., Malcolm, M. A. and Moler, C. B. (1977) Computer Methods for Mathematical Computations. Wiley.

The method to obtain the remaining two conditions described in this book uses the last and first four points at each end of the sequential data to fit a cubic polynomial through them. This is easily possible, as four points suffice to fully define a cubic. From each of these polynomials, the third derivative (constant for cubics) is used as a boundary condition. For sequential data x_1, ... x_n with a spline function s(x) and fitted cubics on either side c_1(x), c_n(x), the two remaining boundary conditions are thus

s'''(x_1) = c_1'''

s'''(x_n) = c_n'''

like image 63
Marco Avatar answered Oct 23 '22 22:10

Marco