splineGrad: Numerical derivatives of a series based on its smooth-spline...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/func_utils.R

Description

This computes the numerical derivatives of a spline representation of the input series; differentiation of spline curves is numerically efficient.

Usage

1
2
3
4
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

smooth.spline, constrain_tapers

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## 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

williamdeleo/psd documentation built on May 29, 2019, 11:58 a.m.