riedsid: Constrained, optimal tapers using the Riedel &...

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

View source: R/func_riedsid.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
riedsid(PSD, ...)

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

## Default S3 method:
riedsid(PSD, ntaper = 1L, tapseq = NULL,
  Deriv.method = c("local_qls", "spg"), constrained = TRUE,
  c.method = NULL, verbose = TRUE, ...)

riedsid2(PSD, ...)

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

## Default S3 method:
riedsid2(PSD, ntaper = 1L, constrained = TRUE,
  verbose = TRUE, ...)

Arguments

PSD

vector or class 'amt' or 'spec'; the spectral values used to optimize taper numbers

...

optional argments passed to constrain_tapers

ntaper

scalar or vector; number of tapers to apply optimization

tapseq

vector; representing positions or frequencies (same length as PSD)

Deriv.method

character; choice of gradient estimation method

constrained

logical; apply constraints with constrain_tapers; FALSE turns off constraints

c.method

string; constraint method to use with constrain_tapers, only if constrained=TRUE

verbose

logical; should messages be printed?

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.

riedsid2 is a new implementation which does not allow for multiple constraint methods; this is the preferred function to use.

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.

Value

Object with class 'tapers'

Warning

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

Author(s)

A.J. Barbour adapted original by R.L. Parker

See Also

constrain_tapers, resample_fft_rcpp, psdcore, pspectrum

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
## Not run: #REX
library(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
x <- 0:(nd-1)
riex <- rnorm(nd) + nrm*abs(cos(pi*x/180) + 1.2)
riex <- riex + 8*nrm*dcauchy(x, nd/3)
riex <- riex + 5*nrm*dnorm(x, nd/2)
# some flat regions
riex[riex<25] <- 25
ried <- dB(riex, invert=TRUE)

# optimize tapers
rtap <- riedsid(riex, ntaper=ntap)
rtap2 <- riedsid2(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), main='Pseudo-spectrum') 
# ... the optimal tapers
plot(rtap2, main='Optimal tapers') 
# original tapers:
lines(rtap, col="red")
par(op)


## End(Not run)#REX

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