Join us for
RADAR: AI Edition

sitar (version 1.0.4)

makess: Create cubic smoothing spline from data

Description

A wrapper to fit a cubic smoothing spline to the supplied data, allowing derivatives to be calculated.

Usage

makess(x, y, xfun, yfun)

Arguments

x
vector giving the values of the predictor variable.
y
vector of responses.
xfun
optional function to be applied to x prior to fitting.
yfun
optional function to be applied to y prior to fitting.

Value

  • An object of class smooth.spline with the extra component apv, a length-2 vector containing the age at peak velocity and peak velocity. If no peak is identified (based on the 2nd derivative changing sign) the values are for maximum rather than peak velocity.

Examples

Run this code
## create smooth.spline mean height curve
data(heights)
ss <- with(heights, makess(age, height))

## and plot it
plot(ss, type='l', xlab='age', ylab='height')

## age at peak velocity, and peak velocity
print(ss$apv)

Run the code above in your browser using DataLab