Description Usage Arguments Details Value Author(s) References Examples
Fits a monotonic cubic spline to the data provided, using the penalized constrained least squares method from the mgcv
package.
1 | makespline(x, y, newX=NULL, nKnots = 6, lower_bound = 10^-3)
|
x |
The predictor variable. |
y |
The response variable. Must be the same length as |
newX |
The points at which to return the value on the fitted spline. If not specified |
nKnots |
The number of knots to use in fitting the spline. |
lower_bound |
The spline cannot drop below this value. |
This uses the pcls
function from the mgcv package to produce the fit. The montonicity constraint is enforced using mono.con
from the same package. The lower_bound
argument is only used on the rare occasions when the fitting function becomes negative or arbitrarily close to zero. If this does occur lower_bound
is added everywhere to ensure that no one length is given essentially infinite weighting.
Returns a vector of values containing the value of the fit at each point newX
.
Matthew D. Young myoung@wehi.edu.au.
Package mgcv. In particular this function is a modification of an example given in the man page for pcls
.
1 2 3 4 5 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.