Learn R Programming

psd (version 0.4-1)

riedsid: Constrained, optimal tapers using the Riedel & Sidorenko--Parker method.

Description

Estimates the optimal number of tapers at each frequency of given PSD, using a modified Riedel-Sidorenko MSE recipe (RS-RLP).

Usage

riedsid(PSD, ntaper, tapseq = NULL, Deriv.method = c("local_qls", "spg"),
  Local.loss = c("Optim", "Less", "More"), constrained = TRUE,
  c.method = NULL, verbose = TRUE, ...)

## S3 method for class 'spec': riedsid(PSD, ...)

## S3 method for class 'default': riedsid(PSD, ntaper, tapseq = NULL, Deriv.method = c("local_qls", "spg"), Local.loss = c("Optim", "Less", "More"), constrained = TRUE, c.method = NULL, verbose = TRUE, ...)

Arguments

PSD
vector or class 'spec'; the spectral values used to optimize taper numbers
ntaper
scalar or vector; number of tapers to apply optimization
tapseq
vector; representing positions or frequencies (same length as PSD)
Deriv.method
character string; choice of gradient estimation method
Local.loss
string; sets how sensitive the spectral derivatives are
constrained
logical; should the taper constraints be applied to the optimum tapers?
c.method
string; constraint method to use if constrained=TRUE
verbose
logical; should messages be printed?
...
optional argments passed to constrain_tapers

Value

  • Object with class 'tapers'.

Warning

The "spg" can become numerically unstable, and it's not clean when it will be preferred to the "local_qls" method other than for efficiency's sake.

Details

The optimization is as follows. First, weighted derivatives of the input PSD are computed. Using those derivates the optimal number of tapers is found through the RS-RLP formulation. Constraints are then placed on the practicable number of tapers.

Taper constraints{ The parameter c.method provides an option to change the method of taper constraints. A description of each may be found in the documentation for constrain_tapers.

Once can use constrained=FALSE to turn off all taper constraints; this could lead to strange behavior though. }

Spectral derivatives{ The parameter Deriv.method determines which method is used to estimate derivatives.

  • "local_qls"
{ (default) uses quadratic weighting and local least-squares estimation; then, Local.loss can alter slightly the weighting to make the derivatives more or less succeptible to changes in spectral values. Can be slower than "spg".} "spg"{ uses splineGrad; then, additional arguments may be passed to control the smoothness of the derivatives (e.g spar in smooth.spline).} }

See Also

constrain_tapers, psdcore, smooth.spline

Examples

Run this code
#RDEX#\dontrun{
require(psd)
##
## Riedel-Sidorenko--Parker taper optimization
##
set.seed(1234)
# some params
nd <- 512 # num data
ntap <- 10 # num tapers
nrm <- 40 # sharpness of the peaks rel 2*variance
#
# create a pseudo spectrum
# with broad peaks
riex <- rnorm(nd) + nrm*abs(cos(pi*(x<-0:(nd-1))/180) + 1.2)
riex <- riex + 8*nrm*dcauchy(x, nd/3)
riex <- riex + 5*nrm*dnorm(x, nd/2)
# flat regions
riex[riex<25] <- 25
ried <- dB(riex, invert=TRUE)
#
# optimize tapers
rtap <- riedsid(riex, ntaper=ntap)
#
# plot
op <- par(no.readonly = TRUE)
par(mfrow=c(2,1), mar=rep(1.3,4), mai=rep(0.6,4))
# ... the mock spectrum
plot(riex, type="h", xaxs="i", ylim=c(0,200)) 
# ... the optimal tapers
plot(rtap, log="y") 
# original tapers:
lines(as.tapers(rep.int(ntap,nd)), col="blue")
par(op)
#RDEX#}

Run the code above in your browser using DataLab