Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

splineGrad

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.

dsig

numeric; a vector of values (which will have a spline fit to them).

...

additional arguments passed to smooth.spline

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

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

psd

Adaptive, Sine-Multitaper Power Spectral Density and Cross Spectrum Estimation

v2.1.0
GPL (>= 2)
Authors
Andrew J. Barbour [aut, cre] (<https://orcid.org/0000-0002-6890-2452>), Jonathan Kennel [aut] (<https://orcid.org/0000-0003-4474-6886>), Robert L. Parker [aut]
Initial release
2020-06-28

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.