1% File src/library/splines/man/interpSpline.Rd 2% Part of the R package, https://www.R-project.org 3% Copyright 1995-2017 R Core Team 4% Distributed under GPL 2 or later 5 6\name{interpSpline} 7\alias{interpSpline} 8\title{Create an Interpolation Spline} 9\description{ 10 Create an interpolation spline, either from \code{x} and \code{y} 11 vectors (\code{default} method), or from a \code{formula} / \code{data.frame} 12 combination (\code{formula} method). 13} 14\usage{ 15interpSpline(obj1, obj2, bSpline = FALSE, period = NULL, 16 ord = 4L, 17 na.action = na.fail, sparse = FALSE) 18} 19\arguments{ 20 \item{obj1}{either a numeric vector of \code{x} values or a formula.} 21 \item{obj2}{if \code{obj1} is numeric this should be a numeric vector 22 of the same length. If \code{obj1} is a formula this can be an 23 optional data frame in which to evaluate the names in the formula.} 24 \item{bSpline}{if \code{TRUE} the b-spline representation is returned, 25 otherwise the piecewise polynomial representation is returned. 26 Defaults to \code{FALSE}.} 27 \item{period}{an optional positive numeric value giving a period for a 28 periodic interpolation spline.} 29 \item{ord}{an integer specifying the spline \emph{order}, the number of 30 coefficients per interval. \eqn{ord = d+1} where \eqn{d} is the 31 \emph{degree} polynomial degree. Currently, only cubic splines 32 (\code{ord = 4}) are implemented.} 33 \item{na.action}{a optional function which indicates what should happen 34 when the data contain \code{NA}s. The default action 35 (\code{na.omit}) is to omit any incomplete observations. The 36 alternative action \code{na.fail} causes \code{interpSpline} to print 37 an error message and terminate if there are any incomplete 38 observations.} 39 \item{sparse}{logical passed to the underlying 40 \code{\link{splineDesign}}. If true, saves memory and is faster when 41 there are more than a few hundred points.} 42} 43\value{ 44 An object that inherits from (S3) class \code{spline}. The object can be in 45 the B-spline representation, in which case it will be of class 46 \code{nbSpline} for natural B-spline, or in the piecewise polynomial 47 representation, in which case it will be of class \code{npolySpline}. 48} 49\author{Douglas Bates and Bill Venables} 50\seealso{ 51 \code{\link{splineKnots}}, 52 \code{\link{splineOrder}}, 53 \code{\link{periodicSpline}}. 54} 55\examples{% tests also in ../tests/spline-tst.R 56require(graphics); require(stats) 57ispl <- interpSpline( women$height, women$weight ) 58ispl2 <- interpSpline( weight ~ height, women ) 59# ispl and ispl2 should be the same 60plot( predict( ispl, seq( 55, 75, length.out = 51 ) ), type = "l" ) 61points( women$height, women$weight ) 62plot( ispl ) # plots over the range of the knots 63points( women$height, women$weight ) 64splineKnots( ispl ) 65} 66\keyword{ models } 67