Learn R Programming

qfa (version 5.0)

tsqr.fit: Trigonometric Spline Quantile Regression (TSQR) of Time Series

Description

This function computes trigonometric spline quantile regression (TSQR) for univariate time series at a single frequency using sqr.fit(), sqr1.fit(), or sqr3.fit().

Usage

tsqr.fit(
  y,
  f0,
  tau,
  tau0 = tau,
  spar = 1,
  w = rep(1, length(tau0)),
  mthreads = FALSE,
  prepared = TRUE,
  method = c("sqr", "sqr1", "sqr3"),
  ztol = NULL,
  solver = NULL,
  all.knots = FALSE,
  control = list()
)

Value

object of sqr.fit(), sqr1.fit(), or sqr3.fit()

Arguments

y

time series

f0

frequency in [0,1)

tau

sequence of quantile levels for evaluation

tau0

sequence of quantile levels for fitting (min(tau0) <= tau <= max(tau0); default = tau)

spar

smoothing parameter (default = 1)

w

weight sequence in penalty (default = rep(1,length(tau0)))

mthreads

if FALSE (default), set RhpcBLASctl::blas_set_num_threads(1)

prepared

if TRUE, intercept is removed and coef of cosine is doubled when f0 = 0.5

method

'sqr' (default), "sqr1", or 'sqr3'

ztol

a zero tolerance paramete to determine the model complexity (default = NULL: set internally to 1e-5 for SQR and SQR1 or 1e-4 for SQR3)

solver

'fnb' or 'sfn' for SQR and SQR1; 'piqp' or 'osqp' for SQR3 (default = NULL: set internally to 'fnb'for SQR and SQR1 or 'piqp' for SQR3)

all.knots

TRUE or FALSE (default), as in stats::smooth.spline()

control

list of control parameters for QP solvers 'piqp' and 'osqp'

Examples

Run this code
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64)
tau <- seq(0.1,0.9,0.05)
tau0 <- seq(0.1,0.9,0.2)
fit <- tqr.fit(y,f0=0.1,tau=tau)
fit.sqr1 <- tsqr.fit(y,f0=0.1,tau=tau,tau0=tau0,spar=0.2,method='sqr1')
fit.sqr3 <- tsqr.fit(y,f0=0.1,tau=tau,tau0=tau0,spar=1,method='sqr3')
plot(tau,fit$coef[1,],type='p',xlab='QUANTILE LEVEL',ylab='TQR COEF')
lines(tau,fit.sqr1$coef[1,])
lines(tau,fit.sqr3$coef[1,],col=2)

Run the code above in your browser using DataLab