TLSWsim {TrendLSW}R Documentation

Simulate Trend Locally Stationary Wavelet Process

Description

Simulates a trend locally stationary wavelet process with a given trend function and spectrum. Extends the LSWsim function from the wavethresh package.

Usage

TLSWsim(
  trend,
  spec,
  filter.number = 4,
  family = "DaubExPhase",
  innov.func,
  ...
)

Arguments

trend

Either:

  • A numeric vector of length n giving the values of the deterministic trend function,

  • A real-valued function of one argument defined on rescaled time [0,1).

When using a numeric vector for trend, if n is not a power of 2 then spec must be specified using a numeric matrix of dimensions \lfloor \log_2 (n) \rfloor \times n.

spec

Either:

  • A wavethresh object of class wd which contains the spectrum for simulating an LSW process,

  • A numeric matrix of dimensions J \times n, where the j-th row corresponds to the spectrum values at scale j and \lfloor \log_2 (n) \rfloor = J,

  • A list of length J=\log_2(n), where the j-th element of the list is a function of one argument specifying the spectrum function at scale j on rescaled time [0,1).

When using a numeric matrix for spec, if n is not a power of 2 then trend must be specified using a numeric vector of length n.

filter.number

The filter number for the wavelet used to simulate the LSW process (default 4)

family

The family of the wavelet used to simulate the LSW process (default DaubExPhase).

innov.func

A function with first argument n used for simulating the innovations. By default, normal random innovations are sampled using the rnorm function.

...

Optional arguments to be passed to the function innov.func for sampling the innovation process.

Value

A n-length vector containing a TLSW process simulated from the trend and spectral description given by the trend and spec arguments.

See Also

LSWsim

Examples


#---- simulate with numeric trend, and spec a wd object as in wavethresh-----

spec <- wavethresh::cns(1024)

spec <- wavethresh::putD(spec, level = 8, seq(from = 2, to = 8, length = 1024))

trend <- sin(pi * (seq(from = 0, to = 4, length = 1024)))

x <- TLSWsim(trend = trend, spec = spec)

plot.ts(x)

#---- simulate with numeric trend, and spec a matrix, with non-dyadic n-----

spec <- matrix(0, nrow = 9, ncol = 1000)

spec[1, ] <- seq(from = 1, to = 10, length = 1000)

trend <- sin(pi * (seq(from = 0, to = 4, length = 1000)))

x <- TLSWsim(trend = trend, spec = spec)

plot.ts(x)

#---- simulate with functional trend, and spec a list of functions-----

spec <- vector(mode = "list", length = 10)

spec[[1]] <- function(u) {
  1 + 9 * u
}

trend <- function(u) {
  sin(pi * u)
}

x <- TLSWsim(trend = trend, spec = spec)

plot.ts(x)


[Package TrendLSW version 1.0.2 Index]