Skip to contents

Code for adaptively spacing knots for a given covariate.

Usage

return.reg.spline.fit(
  response,
  explanatory,
  degree,
  minKnots,
  maxKnots,
  startKnots,
  gap,
  winHalfWidth,
  fitnessMeasure = "BIC",
  maxIterations = 100,
  initialise = TRUE,
  initialKnots = NULL,
  baseModel = NULL,
  bd,
  spl,
  interactionTerm = interactionTerm,
  cv.opts,
  splineParams,
  printout
)

Arguments

response

vector of response data for the modelling process

explanatory

vector of covariate to find knots for

degree

degree of the spline to be used

minKnots

minimum number of knots to fit

maxKnots

maximum number of knots to fit

startKnots

number of equally spaced knots to start with (between minKnots and maxKnots)

gap

minimum gap between knots (in unit of measurement of explanatory)

winHalfWidth

Half-width of window used to calculate region with biggest average residual magnitude

fitnessMeasure

(default=BIC). Measure used to evaluate the fit. Other options are AIC, AICc, BIC, QAIC, QAICc, QBIC (Quasi-Likelihood Information Criterion with log(n) penalty), k-fold cross-validation (cv.gamMRSea), AICtweedie, BICtweedie.

maxIterations

exchange/improve heuristic will terminate after maxIterations if still running

initialise

(default = TRUE). Logical stating whether or not to start with equally spaced knots (TRUE) or user specified locations (FALSE)

initialKnots

If initialise=FALSE then the start locations for the knots are specified in initialKnots

baseModel

starting model for SALSA to use. Must not contain the covariate in explanatory

bd

the x-coordinate of the boundary knots of explanatory

spl

"bs" uses b-spline, "cc" uses cyclic cubic, "ns" uses natural cubic spline for fitting smooth to explanatory

interactionTerm

character stating the variable to use as an interaction

cv.opts

A list object containing options for cv.gamMRSea.

printout

A logical stating whether analysis information is printed in the workspace or into a logfile (TRUE) or not at all (FALSE)

suppress.printout

default=FALSE. If TRUE, progress is printed into the workspace. If FALSE, a .log file is created in the working directory.

Author

Cameron Walker, Department of Engineering Science, University of Auckland, University of Auckland), Lindesay Scott-Hayward (University of St Andrews)