Numerical derivatives of a series based on its smooth-spline representation
This computes the numerical derivatives of a spline representation of the input series; differentiation of spline curves is numerically efficient.
splineGrad(dseq, dsig, ...) ## Default S3 method: splineGrad(dseq, dsig, plot.derivs = FALSE, ...)
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? |
With smoothing, the numerical instability for "noisy" data can be drastically reduced, since spline curves are inherently (at least) twice differentiable.
A matrix with columns representing x, f(x), f'(x), f''(x)
A.J. Barbour
## 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
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.