Differentiating functional data: approximating derivative functions
Source:R/calculus.R
tf_derive.Rd
Derivatives of tf
-objects use finite differences of the evaluations for
tfd
and finite differences of the basis functions for tfb
.
Usage
tf_derive(f, arg, order = 1, ...)
# S3 method for matrix
tf_derive(f, arg, order = 1, ...)
# S3 method for tfd
tf_derive(f, arg, order = 1, ...)
# S3 method for tfb_spline
tf_derive(f, arg, order = 1, ...)
# S3 method for tfb_fpc
tf_derive(f, arg, order = 1, ...)
Arguments
- f
a
tf
-object- arg
grid to use for the finite differences. Not the
arg
of the returned object fortfd
-inputs, see Details.- order
order of differentiation. Maximal value for
tfb_spline
is 2.- ...
not used
Details
The derivatives of tfd
objects use centered finite differences, e.g. for
first derivatives \(f'((t_i + t_{i+1})/2) \approx \frac{f(t_i) +
f(t_{i+1})}{t_{i+1} - t_i}\), so the domains of differentiated tfd
will
shrink (slightly) at both ends. Unless the tfd
has a rather fine and
regular grid, representing the data in a suitable basis representation with
tfb()
and then computing the derivatives or integrals of those is usually
preferable.
Note that, for some spline bases like "cr"
or "tp"
which always begin/end
linearly, computing second derivatives will produce artefacts at the outer
limits of the functions' domain due to these boundary constraints. Basis
"bs"
does not have this problem for sufficiently high orders, but tends to
yield slightly less stable fits.
Methods (by class)
tf_derive(matrix)
: row-wise finite differencestf_derive(tfd)
: derivatives by finite differencing.tf_derive(tfb_spline)
: derivatives by finite differencing.tf_derive(tfb_fpc)
: derivatives by finite differencing.
See also
Other tidyfun calculus functions:
tf_integrate()