Description Usage Arguments Details Value Author(s) References See Also Examples
Least squares splines with variable knots.
1 2 3 4 5 6 7 8 9 10 | #curfit.free.knot(x, y, w=NULL, k = 3, g = 10, eps = 0.5e-3,
# prior = NULL, fixed = NULL, trace=1, ...)
#NOTE: The following is required by CRAN rules that
# function names like "as.numeric" must follow the documentation
# standards for S3 generics, even when they are not.
# Please ignore the following line:
## S3 method for class 'free.knot'
curfit(x, y, w=NULL, k = 3, g = 10, eps = 0.5e-3,
prior = NULL, fixed = NULL, trace=1, ...)
|
x |
A |
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 |
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 |
to |
input |
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 |
fp |
sum of squares residuals. Use |
wrk |
Work space. Do NOT modify before call to |
lwrk |
Length of |
iwrk |
Integer work space. Do NOT modify before call to
|
ier |
Error code. Should always be zero. |
message |
convergence message or character(0) |
g |
Number of interior knots |
method |
input |
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
1 2 3 4 5 6 7 8 9 10 | # Skip this test on CRAN
# because it may exceed their 5 second limit
if(!CRAN()){
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))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.