type_spline | R Documentation |
Type function for plotting a cubic (or Hermite) spline interpolation.
Arguments are passed to spline
; see this latter function
for default argument values.
type_spline(
n = NULL,
method = "fmm",
xmin = NULL,
xmax = NULL,
xout = NULL,
ties = mean
)
n |
if |
method |
specifies the type of spline to be used. Possible
values are |
xmin , xmax |
left-hand and right-hand endpoint of the
interpolation interval (when |
xout |
an optional set of values specifying where interpolation is to take place. |
ties |
handling of tied |
The inputs can contain missing values which are deleted, so at least
one complete (x, y)
pair is required.
If method = "fmm"
, the spline used is that of
Forsythe, Malcolm and Moler
(an exact cubic is fitted through the four points at each
end of the data, and this is used to determine the end conditions).
Natural splines are used when method = "natural"
, and periodic
splines when method = "periodic"
.
The method "monoH.FC"
computes a monotone Hermite spline
according to the method of Fritsch and Carlson. It does so by
determining slopes such that the Hermite spline, determined by
(x_i,y_i,m_i)
, is monotone (increasing or
decreasing) iff the data are.
Method "hyman"
computes a monotone cubic spline using
Hyman filtering of an method = "fmm"
fit for strictly monotonic
inputs.
These interpolation splines can also be used for extrapolation, that is
prediction at points outside the range of x
. Extrapolation
makes little sense for method = "fmm"
; for natural splines it
is linear using the slope of the interpolating curve at the nearest
data point.
# "spline" type convenience string
tinyplot(dist ~ speed, data = cars, type = "spline")
# Use `type_spline()` to pass extra arguments for customization
tinyplot(dist ~ speed, data = cars, type = type_spline(method = "natural", n = 25),
add = TRUE, lty = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.