Learn R Programming

qfa (version 4.1)

qspec.lw: Lag-Window (LW) Estimator of Quantile Spectrum

Description

This function computes lag-window (LW) estimate of quantile spectrum with or without quantile smoothing from time series or quantile autocovariance function (QACF).

Usage

qspec.lw(
  y,
  tau,
  y.qacf = NULL,
  M = NULL,
  method = c("none", "gamm", "sp"),
  spar = "GCV",
  n.cores = 1,
  cl = NULL
)

Value

A list with the following elements:

spec

matrix or array of spectral estimate

spec.lw

matrix or array of spectral estimate without quantile smoothing

lw

lag-window sequence

qacf

matrix or array of quantile autocovariance function if y.qacf = NULL

Arguments

y

vector or matrix of time series (if matrix, nrow(y) = length of time series)

tau

sequence of quantile levels in (0,1)

y.qacf

matrix or array of pre-calculated QACF (default = NULL: compute from y and tau); if y.qacf is supplied, y and tau can be left unspecified

M

bandwidth parameter of lag window (default = NULL: quantile periodogram)

method

quantile smoothing method: "gamm" for mgcv::gamm(), "sp" for stats::smooth.spline(), or "none" (default)

spar

smoothing parameter in smooth.spline() if method = "sp" (default = "GCV")

n.cores

number of cores for parallel computing (default = 1)

cl

pre-existing cluster for repeated parallel computing (default = NULL)

Examples

Run this code
y1 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64)
y2 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64)
tau <- seq(0.1,0.9,0.05)
n <- length(y1)
ff <- c(0:(n-1))/n
sel.f <- which(ff > 0 & ff < 0.5)
y.qacf <- qacf(cbind(y1,y2),tau)
y.qper.lw <- qspec.lw(y.qacf=y.qacf,M=5)$spec
qfa.plot(ff[sel.f],tau,Re(y.qper.lw[1,1,sel.f,]))
y.qper.lwqs <- qspec.lw(y.qacf=y.qacf,M=5,method="sp",spar=0.9)$spec
qfa.plot(ff[sel.f],tau,Re(y.qper.lwqs[1,1,sel.f,]))

Run the code above in your browser using DataLab