splineGrad {psd} | R Documentation |
Numerical derivatives of a series based on its smooth-spline representation
Description
This computes the numerical derivatives of a spline representation of the input series; differentiation of spline curves is numerically efficient.
Usage
splineGrad(dseq, dsig, ...)
## Default S3 method:
splineGrad(dseq, dsig, plot.derivs = FALSE, ...)
Arguments
dseq |
numeric; a vector of positions for |
dsig |
numeric; a vector of values (which will have a spline fit to them). |
... |
additional arguments passed to |
plot.derivs |
logical; should the derivatives be plotted? |
Details
With smoothing, the numerical instability for "noisy" data can be drastically reduced, since spline curves are inherently (at least) twice differentiable.
Value
A matrix with columns representing x, f(x), f'(x), f''(x)
Author(s)
A.J. Barbour
See Also
smooth.spline
, constrain_tapers
Examples
## Not run: #REX
library(psd)
##
## Spline gradient
##
set.seed(1234)
x <- seq(0,5*pi,by=pi/64)
y <- cos(x) #**2
splineGrad(x, y, TRUE)
# unfortunately, the presence of
# noise will affect numerical derivatives
y <- y + rnorm(length(y), sd=.1)
splineGrad(x, y, TRUE)
# so change the smoothing used in smooth.spline
splineGrad(x, y, TRUE, spar=0.2)
splineGrad(x, y, TRUE, spar=0.6)
splineGrad(x, y, TRUE, spar=1.0)
## End(Not run)#REX
[Package psd version 2.1.1 Index]