curfit.free.knot {DierckxSpline} | R Documentation |
Least squares splines with variable knots.
curfit.free.knot(x, y, w=NULL, k = 3, g = 10, eps = 0.5e-3, prior = NULL, fixed = NULL, trace=1, ...)
x |
A data.frame , matrix , or numeric
vector. |
y |
Optional numeric vector. |
w |
Observation weights. |
k |
degree of the spline; k=3 for cubic spline. |
g |
integer vector specifying the number(s) of knots to try.
This is ignored if 'prior' is provided. If(length(g) == 1) g = 1:g. If(length(g)>1) g = seq(min(g), max(g)). |
eps |
weight on the reciprocal differences between successive knots:
penalty = eps*(diff(range(x))/(length(knots)+1)^2) * sigma0 * sum(1/diff(unique(knots)))
|
prior |
initial values for the free knots |
fixed |
locations of fixed knots |
trace |
a number indicating the trace level. If 'g' is parsed as a vector,
then with trace > 0, after a model for each g[i] is fit, the
algorithm reports the number of knots, the variance of the
residuals, and the z-score for the lag 1 autocorrelation of
residuals.
For g[i] > 1, 'optim' is called with control=list(trace=trace-1). |
... |
Additional arguments used by curfit .
|
1. If(!is.null(prior)) fit only a model with that number if free knots.
2. Otherwise, decode 'g' and fit one model for each level of 'g'.
3. Return the first model with a negative lag 1 autocorrelation, if any. Otherwise, return the last model fit.
An object of class dierckx
with the following components:
iopt |
method used |
m |
length of 'x' |
x |
abscissa values |
y |
ordinate values |
w |
input weights |
from |
input from value |
to |
input to value |
k |
degree of the spline |
s |
input smoothing parameter |
nest |
Estimated number of knots |
n |
Actual number of knots |
knots |
Knot locations. |
coef |
b-Spline coefficients. Use coef.dierckx to extract. |
fp |
sum of squares residuals. Use deviance.dierckx to
extract.
|
wrk |
Work space. Do NOT modify before call to update.dierckx
|
lwrk |
Length of wrk . Do NOT modify before call to
update.dierckx
|
iwrk |
Integer work space. Do NOT modify before call to
update.dierckx
|
ier |
Error code. Should always be zero. |
message |
convergence message or character(0) |
g |
Number of interior knots |
method |
input method value, e.g, 'ls' for least squares |
periodic |
logical: TRUE for a periodic spline |
routine |
Always 'curfit.default' |
xlab |
character x axis label for a plot |
ylab |
character y axis label for a plot |
fits |
This component is only present if(is.null(prior)). In that case it is a list with other objects of class 'dierckx' with attributes 'iopt', 'm', 'x', 'y', 'w', 'from', 'to', 'k', 's', 'nest', 'n', 'knots', 'coef', 'fp', 'wrk', 'lwrk', 'iwrk', 'ier', 'message', 'g', 'method', 'periodic', 'routine', 'xlab', 'ylab', as just described, one for each value of 'g' tested. |
summary |
a data.frame with the following columns:
|
Sundar Dorai-Raj
Dierckx, P. (1991) Curve and Surface Fitting with Splines, Oxford Science Publications.
curfit
,
concon
,
spline
,
smooth.spline
data(titanium) titan10 <- with(titanium, curfit.free.knot(x, y)) #titan10.1 <- with(titanium, curfit.free.knot(x, y, k=1)) #titan10.1 <- with(titanium, curfit.free.knot(x, y, k=1, g=8, trace=1.1)) #titan10.1 <- with(titanium, curfit.free.knot(x, y, k=1,g=7:8, trace=1.1))