Learn R Programming

freeknotsplines (version 1.0.1)

freeknotfit: Fit Free-Knot Splines To Data

Description

These functions fit free-knot splines to data with one independent variable and one dependent variable. It is assumed that the number of knots is known in advance. freelsgen and freelsgold fit least-squares splines with no penalty, while freepsgen and freepsgold fit penalized splines. freelsgen and freepsgen use a genetic algorithm, while freelsgold and freepsgold use a blind search augmented with a golden section algorithm.

Usage

freelsgen(x, y, degree, numknot, seed = 5, stream = 0)
freelsgold(x, y, degree, numknot, seed = 5, stream = 0)
freepsgen(x, y, degree, numknot, seed = 5, stream = 0)
freepsgold(x, y, degree, numknot, seed = 5, stream = 0)

Arguments

x

A vector containing the values of the independent variable.

y

A vector containing the values of the dependent variable.

degree

The degree of the spline fit.

numknot

The number of knots.

seed

The value of the initial seed. Defaults to 5.

stream

The value of the initial stream to be used for parallel programming. Defaults to 0.

Value

An object of class "freekt" containing the following components:

x

A vector containing the x values.

y

A vector containing the y values.

degree

The degree of the spline fit.

seed

The value of the initial seed.

stream

The value of the stream.

lambda

The optimum amount of penalty. This is automatically equal to 0 for freelsgen and freelsgold.

optknot

A vector containing the optimal knots.

tracehat

The trace of the hat matrix for the optimal fit.

GCV

The value of generalized cross validation (GCV) for the optimal fit.

GSJS

The GSJS estimator, an estimator of the variance of the data.

call

The function call.

References

Eubank, R. (1999), Nonparametric Regression and Spline Smoothing, New York: Marcel Dekker, Inc., Second ed.

Spiriti, S., Eubank, R., Smith, P., Young, D., "Knot Selection for Least-Squares and Penalized Splines," Journal of Statistical Computation and Simulation, in press.

See Also

fit.search.numknots for the case where the number of knots is not specified in advance.

Examples

Run this code
# NOT RUN {
x <- 0:30/30
truey <- x*sin(10*x)
set.seed(10556)
y <- truey + rnorm(31, 0, 0.2)
xy.freekt <- freelsgen(x, y, degree = 2, numknot = 2, 555)
plot.freekt(xy.freekt, xfit = 0:1000/1000)
# }

Run the code above in your browser using DataLab