Learn R Programming

psd (version 0.4-1)

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

Description

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

Usage

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

tapers(x, min_taper = 1, max_taper = NULL, setspan = 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 it is return?

Value

  • An object with class taper.

Details

Formal requirements enforced by this function are:
  • Non-zero.
  • Integer values.
  • Fewer than the half-length of the spectrum.
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.

See Also

is.tapers

Examples

Run this code
#RDEX#\dontrun{
require(psd)
##
## Objects with class 'tapers'
##
is.tapers(as.tapers(1))
is.tapers(as.tapers(1:10))
is.tapers(as.tapers(matrix(1:10,ncol=1)))
as.tapers(list(x=1:10,y=1:30)) # note dimensions
as.tapers(x<-data.frame(x=1:10,y=10:19))
as.tapers(x, min_taper=3, max_taper=10)
# class 'character' is in-coercible; raise error
try(as.tapers(c("a","b")), silent=TRUE)
#RDEX#}

Run the code above in your browser using DataLab