This section describes a number of functions for fitting piecewise smooth curves to data. Functions in this section are particularly useful for plotting charts; there are even convenience functions for using these functions to show fitted values in some graphics packages.
One method for fitting a function to source data is with splines. With a linear model, a single line is fitted to all the data. With spline methods, a set of different polynomials is fitted to different sections of the data.
You can compute simple cubic splines with the
spline function in the
spline(x, y = NULL, n = 3 * length(x), method = "fmm", xmin = min(x), xmax = max(x), xout, ties = mean)
Here is a description of the arguments to
|x||A vector specifying the predictor variable, or a two-column matrix specifying both the predictor and the response variables.|
|method||Specifies the type of spline. Allowed values include
|xout||An optional vector of values specifying where interpolation should be done.|
|ties||A method for handling ties. Either the string |
To return a function ...