Description Usage Arguments Value Author(s) References See Also Examples

This function fits free-knot splines to data using every value for the number of knots between `minknot`

and `maxknot`

. The number of knots is then chosen to optimize a fit criterion. The free-knot spline with the optimum number of knots is returned.

1 2 3 4 | ```
fit.search.numknots(x, y, degree, minknot = 1, maxknot = 5,
alg = "LS", search = "genetic",
knotnumcrit = "adjGCV", k = 2, d = 3, seed = 5,
stream = 0)
``` |

`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. |

`minknot` |
The minimum number of knots to search. Defaults to 1. |

`maxknot` |
The maximum number of knots to search. Defaults to 5. |

`alg` |
The spline-fitting algorithm. Choices are "LS" for least-squares and "PS" for P-splines. Defaults to "LS." |

`search` |
The random search algorithm. Choices are "genetic" for a genetic algorithm and "golden" for a blind random search with golden section adjustment. Defaults to "genetic." |

`knotnumcrit` |
The criterion to be used for determining the number of knots. Choices are "GCV" for generalized cross-validation, "AIC" for the Akaike information criterion, "AICc" for corrected Akaike information criterion, "BIC" for Bayesian information criterion, "adjAIC" for an adjusted version of the Akaiki information criterion, and "adjGCV" for an adjusted version of generalized cross-validation. Defaults to "adjGCV." |

`k` |
The amount of penalty when AIC is used. Has no effect with criteria other than AIC. Defaults to 2. |

`d` |
The amount of penalty when adjGCV is used. Has no effect with criteria other than adjGCV. Defaults to 3. |

`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. |

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 |

`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. |

Steven Spiriti

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.

`fitcriteria`

for the fit criteria, `freeknotfit`

for the free-knot spline algorithms.

1 2 3 4 5 6 | ```
x <- 0:30/30
truey <- x*sin(10*x)
set.seed(10556)
y <- truey + rnorm(31, 0, 0.2)
xy.freekt <- fit.search.numknots(x, y, degree = 2, minknot = 1, maxknot = 3, seed = 555)
plot.freekt(xy.freekt, xfit = 0:1000/1000)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.