minspan
sets the maximum span a tapers
object may have, which is necessary because it would be
nonsense to have more tapers than the length of the
series.
constrain_tapers
refines the number of
tapers; the method by which it does this is chosen with
the constraint.method
parameter. See
Constraint methods section for descriptions of
each method. Below is a summary of the function
associated with each constraint.method
:
'simple.slope'
usesctap_simple
'loess.smooth'
usesctap_loess
'none'
returns
unbounded tapers.minspan(tapvec, ...) ## S3 method for class 'tapers':
minspan(tapvec, ...)
constrain_tapers(tapvec, tapseq = NULL,
constraint.method = c("simple.slope", "loess.smooth", "none"),
verbose = TRUE, ...)
## S3 method for class 'tapers':
constrain_tapers(tapvec, tapseq = NULL,
constraint.method = c("simple.slope", "loess.smooth", "none"),
verbose = TRUE, ...)
ctap_simple(tapvec, tapseq = NA, maxslope = 1, ...)
## S3 method for class 'tapers':
ctap_simple(tapvec, tapseq = NA,
maxslope = 1, ...)
ctap_loess(tapvec, tapseq = NULL, loess.span = 0.3,
loess.degree = 1, verbose = TRUE, ...)
## S3 method for class 'tapers':
ctap_loess(tapvec, tapseq = NULL,
loess.span = 0.3, loess.degree = 1, verbose = TRUE,
...)
ctap_markov()
## S3 method for class 'tapers':
ctap_markov()
ctap_friedman()
## S3 method for class 'tapers':
ctap_friedman()
'tapers'
object; the number of
tapers at each frequencyloess
'tapers'
.ctap_simple
is the preferred constraint
method. The algortihm uses first-differencing to modify
the number of tapers in the previous position.
Effectively, the constraint is based on a causal,
1st-order Finite Impulse-response Filter (FIR) which
makes the method sensitive to rapid changes in the number
of tapers; naturally, smoother spectra tend to produce
less fluctuation in taper numbers, which makes this well
suited for adaptive processing.This produces, generally, the most stable results, meaning repeatedly running the constraint will not change values other than on the first execution; the same cannot be said for the other methods.
In pure-R this algorithm can be very slow; however, here we have included it as dynamically loaded c-code so it it reasonably fast. }
ctap_loess
uses loess
to smooth the
taper vector; is can be very slow thanks to quadratic
scaling. }
ctap_loess
results tend to be strongly
dependent on the tuning parameters given to loess
(for obvious reasons); hence, some effort should be given
to understand their effect, and/or re-tuning them if
needed.minspan
bounds the number of tapers to
within the minimum of either the maximum number of tapers
found in the object, or the half-length of the series.splineGrad
, riedsid
require(psd)
##
## Taper constraint procedures
##
data(magnet)
X <- magnet$clean
##
## spectrum, then riedsid
kopt <- riedsid(PSD <- psdcore(X, ntaper=10, refresh=TRUE))
kopt.loess <- riedsid(PSD, c.method="loess.smooth")
#
plot(kopt, log="y", ylim =c(.1, 3e2))
lines(kopt.loess, log="y", col="green")
##
##
## To compare all the methods at once:
demo("ctap")
##
Run the code above in your browser using DataLab