as.tapers: Coerce an object into a "tapers" object.

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

View source: R/func_tapers.R

Description

In a tapered spectrum estimation algorithm, it is necessary to enforce rules on the number of tapers that may be applied.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
as.tapers(
  x,
  min_taper = 1,
  max_taper = NULL,
  setspan = FALSE,
  record.last = FALSE
)

tapers(
  x,
  min_taper = 1,
  max_taper = NULL,
  setspan = FALSE,
  record.last = FALSE
)

Arguments

x

An object to set

min_taper

Set all values less than this to this.

max_taper

Set all values greater than this to this.

setspan

logical; should the tapers object be passed through minspan before being returned?

record.last

logical; should the x be saved to the psd-environment before coercion?

Details

Formal requirements enforced by this function are:

For example, we cannot apply zero tapers (the result would be a raw periodogram) or one million tapers (that would be absurd, and violate orthogonality conditions for any series less than two million terms long!).

An object with S3 class 'tapers' is created; this will have a minimum number of tapers in each position set by min_taper, and a maximum number of tapers in each position set by max_taper. If minspan=TRUE, the bounded taper is fed through minspan which will restrict the maximum tapers to less than or equal to the half-length of the spectrum.

Various classes can be coerced into a 'tapers' object; those tested sofar include: scalar, vector, matrix, data.frame, and list.

Multiple objects are concatenated into a single vector dimension.

Enabling setspan will only override max_taper should it be larger than the half-width of the series.

Value

An object with class 'taper'

Note

No support (yet) for use of min_taper,max_taper as vectors, although this could be quite desirable.

Author(s)

A.J. Barbour

See Also

is.tapers

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: #REX
library(psd)

##
## Objects with class 'tapers'
##
is.tapers(as.tapers(1))
is.tapers(as.tapers(1:10))

# note dimensions
as.tapers(matrix(1:10,ncol=1))
as.tapers(list(x=1:10,y=1:30))
as.tapers( x <- data.frame(x=1:10,y=10:19) )

# change constraints
as.tapers(x, min_taper=3, max_taper=10)

# class 'character' is in-coercible; raise error
try(as.tapers(c("a","b")), silent=TRUE)


## End(Not run)#REX

psd documentation built on Feb. 1, 2022, 1:06 a.m.