Title: | Quantile-Frequency Analysis (QFA) of Time Series |
---|---|
Description: | Quantile-frequency analysis (QFA) of univariate or multivariate time series based on trigonometric quantile regression. See Li, T.-H. (2012) "Quantile periodograms", Journal of the American Statistical Association, 107, 765–776, <doi:10.1080/01621459.2012.682815>; Li, T.-H. (2014) Time Series with Mixed Spectra, CRC Press, <doi:10.1201/b15154>; Li, T.-H. (2022) "Quantile Fourier transform, quantile series, and nonparametric estimation of quantile spectra", <doi:10.48550/arXiv.2211.05844>. |
Authors: | Ta-Hsin Li [cre, aut] |
Maintainer: | Ta-Hsin Li <[email protected]> |
License: | GPL (>= 2) |
Version: | 2.1 |
Built: | 2024-11-13 06:31:11 UTC |
Source: | CRAN |
This function computes quantile spectrum/cross-spectrum (QSPEC) from an AR model of quantile series (QSER).
ar2qspec(fit, freq = NULL)
ar2qspec(fit, freq = NULL)
fit |
object of AR model from |
freq |
sequence of frequencies in [0,1) (default = |
a list with the following elements:
spec |
matrix or array of quantile spectrum/cross-spectrum |
freq |
sequence of frequencies |
This function computes quantile autocovariance function (QACF) from time series or quantile discrete Fourier transform (QDFT).
qacf(y, tau, y.qdft = NULL, n.cores = 1, cl = NULL)
qacf(y, tau, y.qdft = NULL, n.cores = 1, cl = NULL)
y |
vector or matrix of time series (if matrix, |
tau |
sequence of quantile levels in (0,1) |
y.qdft |
matrix or array of pre-calculated QDFT (default = |
n.cores |
number of cores for parallel computing of QDFT if |
cl |
pre-existing cluster for repeated parallel computing of QDFT (default = |
matrix or array of quantile autocovariance function
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) # compute from time series y.qacf <- qacf(y,tau) # compute from QDFT y.qdft <- qdft(y,tau) y.qacf <- qacf(y.qdft=y.qdft)
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) # compute from time series y.qacf <- qacf(y,tau) # compute from QDFT y.qdft <- qdft(y,tau) y.qacf <- qacf(y.qdft=y.qdft)
This function computes quantile discrete Fourier transform (QDFT) for univariate or multivariate time series.
qdft(y, tau, n.cores = 1, cl = NULL)
qdft(y, tau, n.cores = 1, cl = NULL)
y |
vector or matrix of time series (if matrix, |
tau |
sequence of quantile levels in (0,1) |
n.cores |
number of cores for parallel computing (default = 1) |
cl |
pre-existing cluster for repeated parallel computing (default = |
matrix or array of quantile discrete Fourier transform of y
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) y.qdft <- qdft(y,tau) # Make a cluster for repeated use n.cores <- 2 cl <- parallel::makeCluster(n.cores) parallel::clusterExport(cl, c("tqr.fit")) doParallel::registerDoParallel(cl) y1 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) y.qdft <- qdft(y1,tau,n.cores=n.cores,cl=cl) y2 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) y.qdft <- qdft(y2,tau,n.cores=n.cores,cl=cl) parallel::stopCluster(cl)
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) y.qdft <- qdft(y,tau) # Make a cluster for repeated use n.cores <- 2 cl <- parallel::makeCluster(n.cores) parallel::clusterExport(cl, c("tqr.fit")) doParallel::registerDoParallel(cl) y1 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) y.qdft <- qdft(y1,tau,n.cores=n.cores,cl=cl) y2 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) y.qdft <- qdft(y2,tau,n.cores=n.cores,cl=cl) parallel::stopCluster(cl)
This function computes quantile autocovariance function (QACF) from QDFT.
qdft2qacf(y.qdft, return.qser = FALSE)
qdft2qacf(y.qdft, return.qser = FALSE)
y.qdft |
matrix or array of QDFT from |
return.qser |
if |
matrix or array of quantile autocovariance function if return.sqer = FALSE
(default), else a list with the following elements:
qacf |
matirx or array of quantile autocovariance function |
qser |
matrix or array of quantile series |
# single time series y1 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) y.qdft <- qdft(y1,tau) y.qacf <- qdft2qacf(y.qdft) plot(c(0:9),y.qacf[c(1:10),1],type='h',xlab="LAG",ylab="QACF") y.qser <- qdft2qacf(y.qdft,return.qser=TRUE)$qser plot(y.qser[,1],type='l',xlab="TIME",ylab="QSER") # multiple time series y2 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) y.qdft <- qdft(cbind(y1,y2),tau) y.qacf <- qdft2qacf(y.qdft) plot(c(0:9),y.qacf[1,2,c(1:10),1],type='h',xlab="LAG",ylab="QACF")
# single time series y1 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) y.qdft <- qdft(y1,tau) y.qacf <- qdft2qacf(y.qdft) plot(c(0:9),y.qacf[c(1:10),1],type='h',xlab="LAG",ylab="QACF") y.qser <- qdft2qacf(y.qdft,return.qser=TRUE)$qser plot(y.qser[,1],type='l',xlab="TIME",ylab="QSER") # multiple time series y2 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) y.qdft <- qdft(cbind(y1,y2),tau) y.qacf <- qdft2qacf(y.qdft) plot(c(0:9),y.qacf[1,2,c(1:10),1],type='h',xlab="LAG",ylab="QACF")
This function computes quantile periodogram/cross-periodogram (QPER) from QDFT.
qdft2qper(y.qdft)
qdft2qper(y.qdft)
y.qdft |
matrix or array of QDFT from |
matrix or array of quantile periodogram/cross-periodogram
# single time series y1 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) y.qdft <- qdft(y1,tau) y.qper <- qdft2qper(y.qdft) n <- length(y1) ff <- c(0:(n-1))/n sel.f <- which(ff > 0 & ff < 0.5) qfa.plot(ff[sel.f],tau,Re(y.qper[sel.f,])) # multiple time series y2 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) y.qdft <- qdft(cbind(y1,y2),tau) y.qper <- qdft2qper(y.qdft) qfa.plot(ff[sel.f],tau,Re(y.qper[1,1,sel.f,])) qfa.plot(ff[sel.f],tau,Re(y.qper[1,2,sel.f,]))
# single time series y1 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) y.qdft <- qdft(y1,tau) y.qper <- qdft2qper(y.qdft) n <- length(y1) ff <- c(0:(n-1))/n sel.f <- which(ff > 0 & ff < 0.5) qfa.plot(ff[sel.f],tau,Re(y.qper[sel.f,])) # multiple time series y2 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) y.qdft <- qdft(cbind(y1,y2),tau) y.qper <- qdft2qper(y.qdft) qfa.plot(ff[sel.f],tau,Re(y.qper[1,1,sel.f,])) qfa.plot(ff[sel.f],tau,Re(y.qper[1,2,sel.f,]))
This function computes quantile series (QSER) from QDFT.
qdft2qser(y.qdft)
qdft2qser(y.qdft)
y.qdft |
matrix or array of QDFT from |
matrix or array of quantile series
# single time series y1 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) y.qdft <- qdft(y1,tau) y.qser <- qdft2qser(y.qdft) plot(y.qser[,1],type='l',xlab="TIME",ylab="QSER") # multiple time series y2 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) y.qdft <- qdft(cbind(y1,y2),tau) y.qser <- qdft2qser(y.qdft) plot(y.qser[1,,1],type='l',xlab="TIME",ylab="QSER")
# single time series y1 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) y.qdft <- qdft(y1,tau) y.qser <- qdft2qser(y.qdft) plot(y.qser[,1],type='l',xlab="TIME",ylab="QSER") # multiple time series y2 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) y.qdft <- qdft(cbind(y1,y2),tau) y.qser <- qdft2qser(y.qdft) plot(y.qser[1,,1],type='l',xlab="TIME",ylab="QSER")
This function creates an image plot of quantile spectrum.
qfa.plot( freq, tau, rqper, rg.qper = range(rqper), rg.tau = range(tau), rg.freq = c(0, 0.5), color = colorRamps::matlab.like2(1024), ylab = "QUANTILE LEVEL", xlab = "FREQUENCY", tlab = NULL, set.par = TRUE, legend.plot = TRUE )
qfa.plot( freq, tau, rqper, rg.qper = range(rqper), rg.tau = range(tau), rg.freq = c(0, 0.5), color = colorRamps::matlab.like2(1024), ylab = "QUANTILE LEVEL", xlab = "FREQUENCY", tlab = NULL, set.par = TRUE, legend.plot = TRUE )
freq |
sequence of frequencies in (0,0.5) at which quantile spectrum is evaluated |
tau |
sequence of quantile levels in (0,1) at which quantile spectrum is evaluated |
rqper |
real-valued matrix of quantile spectrum evaluated on the |
rg.qper |
|
rg.tau |
|
rg.freq |
|
color |
colors (default = |
ylab |
label of y-axis (default = |
xlab |
label of x-axis (default = |
tlab |
title of plot (default = |
set.par |
if |
legend.plot |
if |
no return value
This function computes Kullback-Leibler divergence (KLD) of quantile spectral estimate.
qkl.divergence(y.qper, qspec, sel.f = NULL, sel.tau = NULL)
qkl.divergence(y.qper, qspec, sel.f = NULL, sel.tau = NULL)
y.qper |
matrix or array of quantile spectral estimate from, e.g., |
qspec |
matrix of array of true quantile spectrum/cross-spectrum (same dimension as |
sel.f |
index of selected frequencies for computation (default = |
sel.tau |
index of selected quantile levels for computation (default = |
real number of Kullback-Leibler divergence
This function computes quantile periodogram/cross-periodogram (QPER) from time series or quantile discrete Fourier transform (QDFT).
qper(y, tau, y.qdft = NULL, n.cores = 1, cl = NULL)
qper(y, tau, y.qdft = NULL, n.cores = 1, cl = NULL)
y |
vector or matrix of time series (if matrix, |
tau |
sequence of quantile levels in (0,1) |
y.qdft |
matrix or array of pre-calculated QDFT (default = |
n.cores |
number of cores for parallel computing of QDFT if |
cl |
pre-existing cluster for repeated parallel computing of QDFT (default = |
matrix or array of quantile periodogram/cross-periodogram
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) # compute from time series y.qper <- qper(y,tau) # compute from QDFT y.qdft <- qdft(y,tau) y.qper <- qper(y.qdft=y.qdft)
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) # compute from time series y.qper <- qper(y,tau) # compute from QDFT y.qdft <- qdft(y,tau) y.qper <- qper(y.qdft=y.qdft)
This function computes type-II quantile periodogram for univariate time series.
qper2(y, freq, tau, weights = NULL, n.cores = 1, cl = NULL)
qper2(y, freq, tau, weights = NULL, n.cores = 1, cl = NULL)
y |
univariate time series |
freq |
sequence of frequencies in [0,1) |
tau |
sequence of quantile levels in (0,1) |
weights |
sequence of weights in quantile regression (default = |
n.cores |
number of cores for parallel computing (default = 1) |
cl |
pre-existing cluster for repeated parallel computing (default = |
matrix of quantile periodogram evaluated on freq * tau
grid
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) n <- length(y) ff <- c(0:(n-1))/n sel.f <- which(ff > 0 & ff < 0.5) y.qper2 <- qper2(y,ff,tau) qfa.plot(ff[sel.f],tau,Re(y.qper2[sel.f,]))
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) n <- length(y) ff <- c(0:(n-1))/n sel.f <- which(ff > 0 & ff < 0.5) y.qper2 <- qper2(y,ff,tau) qfa.plot(ff[sel.f],tau,Re(y.qper2[sel.f,]))
This function computes quantile series (QSER) from time series or quantile discrete Fourier transform (QDFT).
qser(y, tau, y.qdft = NULL, n.cores = 1, cl = NULL)
qser(y, tau, y.qdft = NULL, n.cores = 1, cl = NULL)
y |
vector or matrix of time series (if matrix, |
tau |
sequence of quantile levels in (0,1) |
y.qdft |
matrix or array of pre-calculated QDFT (default = |
n.cores |
number of cores for parallel computing of QDFT if |
cl |
pre-existing cluster for repeated parallel computing of QDFT (default = |
matrix or array of quantile series
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) # compute from time series y.qser <- qser(y,tau) # compute from QDFT y.qdft <- qdft(y,tau) y.qser <- qser(y.qdft=y.qdft)
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) # compute from time series y.qser <- qser(y,tau) # compute from QDFT y.qdft <- qdft(y,tau) y.qser <- qser(y.qdft=y.qdft)
This function fits an autoregression (AR) model to quantile series (QSER) separately for each quantile level using stats::ar()
.
qser2ar(y.qser, p = NULL, order.max = NULL)
qser2ar(y.qser, p = NULL, order.max = NULL)
y.qser |
matrix or array of pre-calculated QSER, e.g., using |
p |
order of AR model (default = |
order.max |
maximum order for AIC if |
a list with the following elements:
A |
matrix or array of AR coefficients |
V |
vector or matrix of residual covariance |
p |
order of AR model |
n |
length of time series |
residuals |
matrix or array of residuals |
This function fits spline autoregression (SAR) model to quantile series (QSER).
qser2sar( y.qser, tau, d = 1, p = NULL, order.max = NULL, spar = NULL, method = c("AIC", "BIC", "GCV"), weighted = FALSE )
qser2sar( y.qser, tau, d = 1, p = NULL, order.max = NULL, spar = NULL, method = c("AIC", "BIC", "GCV"), weighted = FALSE )
y.qser |
matrix or array of pre-calculated QSER, e.g., using |
tau |
sequence of quantile levels where |
d |
subsampling rate of quantile levels (default = 1) |
p |
order of SAR model (default = |
order.max |
maximum order for AIC if |
spar |
penalty parameter alla |
method |
criterion for penalty parameter selection: |
weighted |
if |
a list with the following elements:
A |
matrix or array of SAR coefficients |
V |
vector or matrix of SAR residual covariance |
p |
order of SAR model |
spar |
penalty parameter |
tau |
sequence of quantile levels |
n |
length of time series |
d |
subsampling rate of quantile levels |
weighted |
option for weighted penalty function |
fit |
object containing details of SAR fit |
This function computes quantile-smoothed version of quantile discrete Fourier transform (QDFT).
qsmooth.qdft( y.qdft, method = c("gamm", "sp"), spar = "GCV", n.cores = 1, cl = NULL )
qsmooth.qdft( y.qdft, method = c("gamm", "sp"), spar = "GCV", n.cores = 1, cl = NULL )
y.qdft |
matrix or array of QDFT from |
method |
smoothing method: |
spar |
smoothing parameter in |
n.cores |
number of cores for parallel computing (default = 1) |
cl |
pre-existing cluster for repeated parallel computing (default = NULL) |
matrix or array of quantile-smoothed QDFT
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.qdft <- qdft(cbind(y1,y2),tau) y.qdft <- qsmooth.qdft(y.qdft,method="sp",spar=0.9) y.qacf <- qdft2qacf(y.qdft) y.qper.qslw <- qspec.lw(y.qacf,M=5)$spec qfa.plot(ff[sel.f],tau,Re(y.qper.qslw[1,1,sel.f,]))
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.qdft <- qdft(cbind(y1,y2),tau) y.qdft <- qsmooth.qdft(y.qdft,method="sp",spar=0.9) y.qacf <- qdft2qacf(y.qdft) y.qper.qslw <- qspec.lw(y.qacf,M=5)$spec qfa.plot(ff[sel.f],tau,Re(y.qper.qslw[1,1,sel.f,]))
This function computes quantile-smoothed version of quantile periodogram/cross-periodogram (QPER) or other quantile spectral estimate.
qsmooth.qper( y.qper, method = c("gamm", "sp"), spar = "GCV", n.cores = 1, cl = NULL )
qsmooth.qper( y.qper, method = c("gamm", "sp"), spar = "GCV", n.cores = 1, cl = NULL )
y.qper |
matrix or array of quantile periodogram/cross-periodogram or spectral estimate |
method |
smoothing method: |
spar |
smoothing parameter in |
n.cores |
number of cores for parallel computing (default = 1) |
cl |
pre-existing cluster for repeated parallel computing (default = |
matrix or array of quantile-smoothed quantile spectral estimate
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.qdft <- qdft(cbind(y1,y2),tau) y.qacf <- qdft2qacf(y.qdft) y.qper.lw <- qspec.lw(y.qacf,M=5)$spec qfa.plot(ff[sel.f],tau,Re(y.qper.lw[1,1,sel.f,])) y.qper.lwqs <- qsmooth.qper(y.qper.lw,method="sp",spar=0.9) qfa.plot(ff[sel.f],tau,Re(y.qper.lwqs[1,1,sel.f,]))
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.qdft <- qdft(cbind(y1,y2),tau) y.qacf <- qdft2qacf(y.qdft) y.qper.lw <- qspec.lw(y.qacf,M=5)$spec qfa.plot(ff[sel.f],tau,Re(y.qper.lw[1,1,sel.f,])) y.qper.lwqs <- qsmooth.qper(y.qper.lw,method="sp",spar=0.9) qfa.plot(ff[sel.f],tau,Re(y.qper.lwqs[1,1,sel.f,]))
This function computes autoregression (AR) estimate of quantile spectrum/cross-spectrum from time series or quantile series (QSER).
qspec.ar( y, tau, y.qser = NULL, p = NULL, order.max = NULL, freq = NULL, n.cores = 1, cl = NULL )
qspec.ar( y, tau, y.qser = NULL, p = NULL, order.max = NULL, freq = NULL, n.cores = 1, cl = NULL )
y |
vector or matrix of time series (if matrix, |
tau |
sequence of quantile levels in (0,1) |
y.qser |
matrix or array of pre-calculated QSER (default = |
p |
order of AR model (default = |
order.max |
maximum order for AIC if |
freq |
sequence of frequencies in [0,1) (default = |
n.cores |
number of cores for parallel computing of QDFT if |
cl |
pre-existing cluster for repeated parallel computing of QDFT (default = |
a list with the following elements:
spec |
matrix or array of AR quantile spectrum/cross-spectrum |
freq |
sequence of frequencies |
fit |
object of AR model |
qser |
matrix or array of quantile series if |
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.ar <- qspec.ar(cbind(y1,y2),tau,p=1) qfa.plot(ff[sel.f],tau,Re(y.ar$spec[1,1,sel.f,]))
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.ar <- qspec.ar(cbind(y1,y2),tau,p=1) qfa.plot(ff[sel.f],tau,Re(y.ar$spec[1,1,sel.f,]))
This function computes lag-window (LW) estimate of quantile spectrum/cross-spectrum from QACF.
qspec.lw(y.qacf, M = NULL)
qspec.lw(y.qacf, M = NULL)
y.qacf |
matrix or array of pre-calculated QACF from |
M |
bandwidth parameter of lag window (default = |
A list with the following elements:
spec |
matrix or array of quantile spectrum/cross-spectrum |
lw |
lag-window sequence |
# single time series y1 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) y.qdft <- qdft(y1,tau) y.qacf <- qdft2qacf(y.qdft) y.qper.lw <- qspec.lw(y.qacf,M=5)$spec n <- length(y1) ff <- c(0:(n-1))/n sel.f <- which(ff > 0 & ff < 0.5) qfa.plot(ff[sel.f],tau,Re(y.qper.lw[sel.f,])) # multiple time series y2 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) y.qdft <- qdft(cbind(y1,y2),tau) y.qacf <- qdft2qacf(y.qdft) y.qper.lw <- qspec.lw(y.qacf,M=5)$spec qfa.plot(ff[sel.f],tau,Re(y.qper.lw[1,2,sel.f,]))
# single time series y1 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) y.qdft <- qdft(y1,tau) y.qacf <- qdft2qacf(y.qdft) y.qper.lw <- qspec.lw(y.qacf,M=5)$spec n <- length(y1) ff <- c(0:(n-1))/n sel.f <- which(ff > 0 & ff < 0.5) qfa.plot(ff[sel.f],tau,Re(y.qper.lw[sel.f,])) # multiple time series y2 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) y.qdft <- qdft(cbind(y1,y2),tau) y.qacf <- qdft2qacf(y.qdft) y.qper.lw <- qspec.lw(y.qacf,M=5)$spec qfa.plot(ff[sel.f],tau,Re(y.qper.lw[1,2,sel.f,]))
This function computes lag-window-quantile-smoothing (LWQS) estimate of quantile spectrum/cross-spectrum from time series or quantile autocovariance function (QACF).
qspec.lwqs( y, tau, y.qacf = NULL, M = NULL, method = c("gamm", "sp"), spar = "GCV", n.cores = 1, cl = NULL )
qspec.lwqs( y, tau, y.qacf = NULL, M = NULL, method = c("gamm", "sp"), spar = "GCV", n.cores = 1, cl = NULL )
y |
vector or matrix of time series (if matrix, |
tau |
sequence of quantile levels in (0,1) |
y.qacf |
matrix or array of pre-calculated QACF (default = |
M |
bandwidth parameter of lag window (default = |
method |
smoothing method: |
spar |
smoothing parameter in |
n.cores |
number of cores for parallel computing (default = 1) |
cl |
pre-existing cluster for repeated parallel computing (default = |
A list with the following elements:
spec |
matrix or array of quantile spectrum/cross-spectrum |
spec.lw |
matrix or array of quantile spectrum/cross-spectrum without quantile smoothing |
lw |
lag-window sequence |
qacf |
matrix or array of quantile autocovariance function if |
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.qper.lwqs <- qspec.lwqs(cbind(y1,y2),tau,M=5,method="sp",spar=0.9)$spec qfa.plot(ff[sel.f],tau,Re(y.qper.lwqs[1,1,sel.f,]))
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.qper.lwqs <- qspec.lwqs(cbind(y1,y2),tau,M=5,method="sp",spar=0.9)$spec qfa.plot(ff[sel.f],tau,Re(y.qper.lwqs[1,1,sel.f,]))
This function computes quantie-smoothing-lag-window (QSLW estimate of quantile spectrum/cross-spectrum from time series or quantile discrete Fourier transform (QDFT).
qspec.qslw( y, tau, y.qdft = NULL, M = NULL, method = c("gamm", "sp"), spar = "GCV", n.cores = 1, cl = NULL )
qspec.qslw( y, tau, y.qdft = NULL, M = NULL, method = c("gamm", "sp"), spar = "GCV", n.cores = 1, cl = NULL )
y |
vector or matrix of time series (if matrix, |
tau |
sequence of quantile levels in (0,1) |
y.qdft |
matrix or array of pre-calculated QDFT (default = |
M |
bandwidth parameter of lag window (default = |
method |
smoothing method: |
spar |
smoothing parameter in |
n.cores |
number of cores for parallel computing (default = 1) |
cl |
pre-existing cluster for repeated parallel computing (default = |
A list with the following elements:
spec |
matrix or array of quantile spectrum/cross-spectrum |
lw |
lag-window sequence |
qdft |
matrix or array of quantile discrete Fourier transform if |
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.qper.qslw <- qspec.qslw(cbind(y1,y2),tau,M=5,method="sp",spar=0.9)$spec qfa.plot(ff[sel.f],tau,Re(y.qper.qslw[1,1,sel.f,]))
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.qper.qslw <- qspec.qslw(cbind(y1,y2),tau,M=5,method="sp",spar=0.9)$spec qfa.plot(ff[sel.f],tau,Re(y.qper.qslw[1,1,sel.f,]))
This function computes spline autoregression (SAR) estimate of quantile spectrum/cross-spectrum.
qspec.sar( y, y.qser = NULL, tau, d = 1, p = NULL, order.max = NULL, spar = NULL, method = c("AIC", "BIC", "GCV"), weighted = FALSE, freq = NULL, n.cores = 1, cl = NULL )
qspec.sar( y, y.qser = NULL, tau, d = 1, p = NULL, order.max = NULL, spar = NULL, method = c("AIC", "BIC", "GCV"), weighted = FALSE, freq = NULL, n.cores = 1, cl = NULL )
y |
vector or matrix of time series (if matrix, |
y.qser |
matrix or array of pre-calculated QSER (default = |
tau |
sequence of quantile levels in (0,1) |
d |
subsampling rate of quantile levels (default = 1) |
p |
order of SAR model (default = |
order.max |
maximum order for AIC if |
spar |
penalty parameter alla |
method |
criterion for penalty parameter selection: |
weighted |
if |
freq |
sequence of frequencies in [0,1) (default = |
n.cores |
number of cores for parallel computing of QDFT if |
cl |
pre-existing cluster for repeated parallel computing of QDFT (default = |
a list with the following elements:
spec |
matrix or array of SAR quantile spectrum |
freq |
sequence of frequencies |
fit |
object of SAR model |
qser |
matrix or array of quantile series if |
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) # compute from time series y.sar <- qspec.sar(cbind(y1,y2),tau=tau,p=1) qfa.plot(ff[sel.f],tau,Re(y.sar$spec[1,1,sel.f,])) # compute from quantile series y.qser <- qser(cbind(y1,y2),tau) y.sar <- qspec.sar(y.qser=y.qser,tau=tau,p=1) qfa.plot(ff[sel.f],tau,Re(y.sar$spec[1,1,sel.f,]))
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) # compute from time series y.sar <- qspec.sar(cbind(y1,y2),tau=tau,p=1) qfa.plot(ff[sel.f],tau,Re(y.sar$spec[1,1,sel.f,])) # compute from quantile series y.qser <- qser(cbind(y1,y2),tau) y.sar <- qspec.sar(y.qser=y.qser,tau=tau,p=1) qfa.plot(ff[sel.f],tau,Re(y.sar$spec[1,1,sel.f,]))
This function computes spline-quantile-regression-lag-window (SQRLW) estimate of quantile spectrum/cross-spectrum from time series or spline quantile discrete Fourier transform (SQDFT).
qspec.sqrlw( y, tau, y.sqdft = NULL, M = NULL, c0 = 0.02, d = 4, weighted = FALSE, n.cores = 1, cl = NULL )
qspec.sqrlw( y, tau, y.sqdft = NULL, M = NULL, c0 = 0.02, d = 4, weighted = FALSE, n.cores = 1, cl = NULL )
y |
vector or matrix of time series (if matrix, |
tau |
sequence of quantile levels in (0,1) |
y.sqdft |
matrix or array of pre-calculated SQDFT (default = |
M |
bandwidth parameter of lag window (default = |
c0 |
penalty parameter for SQDFT |
d |
subsampling rate of quantile levels for SQDFT (default = 1) |
weighted |
if |
n.cores |
number of cores for parallel computing of SQDFT (default = 1) |
cl |
pre-existing cluster for repeated parallel computing of SQDFT (default = |
A list with the following elements:
spec |
matrix or array of quantile spectrum/cross-spectrum |
lw |
lag-window sequence |
sqdft |
matrix or array of spline quantile discrete Fourier transform if |
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.qper.sqrlw <- qspec.sqrlw(cbind(y1,y2),tau,M=5,c0=0.02,d=4)$spec qfa.plot(ff[sel.f],tau,Re(y.qper.sqrlw[1,1,sel.f,]))
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.qper.sqrlw <- qspec.sqrlw(cbind(y1,y2),tau,M=5,c0=0.02,d=4)$spec qfa.plot(ff[sel.f],tau,Re(y.qper.sqrlw[1,1,sel.f,]))
This function computes quantile coherence spectrum (QCOH) from quantile spectrum and cross-spectrum of multiple time series.
qspec2qcoh(qspec, k = 1, kk = 2)
qspec2qcoh(qspec, k = 1, kk = 2)
qspec |
array of quantile spectrum/cross-spectrum |
k |
index of first series (default = 1) |
kk |
index of second series (default = 2) |
matrix of quantile coherence evaluated at Fourier frequencies in (0,0.5)
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,M=5)$spec y.qcoh <- qspec2qcoh(y.qper.lw,k=1,kk=2) qfa.plot(ff[sel.f],tau,y.qcoh)
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,M=5)$spec y.qcoh <- qspec2qcoh(y.qper.lw,k=1,kk=2) qfa.plot(ff[sel.f],tau,y.qcoh)
This function simulates bootstrap samples of selected spline autoregression (SAR) coefficients for testing equality of Granger-causality in two samples based on their SAR models under H0: effect in each sample equals the average effect.
sar.eq.bootstrap( y.qser, fit, fit2, index = c(1, 2), nsim = 1000, method = c("ar", "sar"), n.cores = 1, mthreads = FALSE, seed = 1234567 )
sar.eq.bootstrap( y.qser, fit, fit2, index = c(1, 2), nsim = 1000, method = c("ar", "sar"), n.cores = 1, mthreads = FALSE, seed = 1234567 )
y.qser |
matrix or array of QSER from |
fit |
object of SAR model from |
fit2 |
object of SAR model for the other sample |
index |
a pair of component indices for multiple time series
or a sequence of lags for single time series (default = |
nsim |
number of bootstrap samples (default = 1000) |
method |
method of residual calculation: |
n.cores |
number of cores for parallel computing (default = 1) |
mthreads |
if |
seed |
seed for random sampling (default = |
array of simulated bootstrap samples of selected SAR coefficients
y11 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) y21 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) y12 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) y22 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) tau <- seq(0.1,0.9,0.05) y1.sar <- qspec.sar(cbind(y11,y21),tau=tau,p=1) y2.sar <- qspec.sar(cbind(y12,y22),tau=tau,p=1) A1.sim <- sar.eq.bootstrap(y1.sar$qser,y1.sar$fit,y2.sar$fit,index=c(1,2),nsim=5) A2.sim <- sar.eq.bootstrap(y2.sar$qser,y2.sar$fit,y1.sar$fit,index=c(1,2),nsim=5)
y11 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) y21 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) y12 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) y22 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) tau <- seq(0.1,0.9,0.05) y1.sar <- qspec.sar(cbind(y11,y21),tau=tau,p=1) y2.sar <- qspec.sar(cbind(y12,y22),tau=tau,p=1) A1.sim <- sar.eq.bootstrap(y1.sar$qser,y1.sar$fit,y2.sar$fit,index=c(1,2),nsim=5) A2.sim <- sar.eq.bootstrap(y2.sar$qser,y2.sar$fit,y1.sar$fit,index=c(1,2),nsim=5)
This function computes Wald test and confidence band for equality of Granger-causality in two samples
using bootstrap samples generated by sar.eq.bootstrap()
based on the spline autoregression (SAR) models
of quantile series (QSER).
sar.eq.test(A1, A1.sim, A2, A2.sim, sel.lag = NULL, sel.tau = NULL)
sar.eq.test(A1, A1.sim, A2, A2.sim, sel.lag = NULL, sel.tau = NULL)
A1 |
matrix of selected SAR coefficients for sample 1 |
A1.sim |
simulated bootstrap samples from |
A2 |
matrix of selected SAR coefficients for sample 2 |
A2.sim |
simulated bootstrap samples from |
sel.lag |
indices of time lags for Wald test (default = |
sel.tau |
indices of quantile levels for Wald test (default = |
a list with the following elements:
test |
list of Wald test result containing |
D.u |
matrix of upper limits of 95% confidence band for |
D.l |
matrix of lower limits of 95% confidence band for |
y11 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) y21 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) y12 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) y22 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) tau <- seq(0.1,0.9,0.05) y1.sar <- qspec.sar(cbind(y11,y21),tau=tau,p=1) y2.sar <- qspec.sar(cbind(y12,y22),tau=tau,p=1) A1.sim <- sar.eq.bootstrap(y1.sar$qser,y1.sar$fit,y2.sar$fit,index=c(1,2),nsim=5) A2.sim <- sar.eq.bootstrap(y2.sar$qser,y2.sar$fit,y1.sar$fit,index=c(1,2),nsim=5) A1 <- sar.gc.coef(y1.sar$fit,index=c(1,2)) A2 <- sar.gc.coef(y2.sar$fit,index=c(1,2)) test <- sar.eq.test(A1,A1.sim,A2,A2.sim,sel.lag=NULL,sel.tau=NULL)
y11 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) y21 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) y12 <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) y22 <- stats::arima.sim(list(order=c(1,0,0), ar=-0.5), n=64) tau <- seq(0.1,0.9,0.05) y1.sar <- qspec.sar(cbind(y11,y21),tau=tau,p=1) y2.sar <- qspec.sar(cbind(y12,y22),tau=tau,p=1) A1.sim <- sar.eq.bootstrap(y1.sar$qser,y1.sar$fit,y2.sar$fit,index=c(1,2),nsim=5) A2.sim <- sar.eq.bootstrap(y2.sar$qser,y2.sar$fit,y1.sar$fit,index=c(1,2),nsim=5) A1 <- sar.gc.coef(y1.sar$fit,index=c(1,2)) A2 <- sar.gc.coef(y2.sar$fit,index=c(1,2)) test <- sar.eq.test(A1,A1.sim,A2,A2.sim,sel.lag=NULL,sel.tau=NULL)
This function simulates bootstrap samples of selected spline autoregression (SAR) coefficients
for Granger-causality analysis based on the SAR model of quantile series (QSER) under H0:
(a) for multiple time series, the second series specified in index
is not causal
for the first series specified in index
;
(b) for single time series, the series is not causal at the lags specified in index
.
sar.gc.bootstrap( y.qser, fit, index = c(1, 2), nsim = 1000, method = c("ar", "sar"), n.cores = 1, mthreads = FALSE, seed = 1234567 )
sar.gc.bootstrap( y.qser, fit, index = c(1, 2), nsim = 1000, method = c("ar", "sar"), n.cores = 1, mthreads = FALSE, seed = 1234567 )
y.qser |
matrix or array of QSER from |
fit |
object of SAR model from |
index |
a pair of component indices for multiple time series
or a sequence of lags for single time series (default = |
nsim |
number of bootstrap samples (default = 1000) |
method |
method of residual calculation: |
n.cores |
number of cores for parallel computing (default = 1) |
mthreads |
if |
seed |
seed for random sampling (default = |
array of simulated bootstrap samples of selected SAR coefficients
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) y.sar <- qspec.sar(cbind(y1,y2),tau=tau,p=1) A.sim <- sar.gc.bootstrap(y.sar$qser,y.sar$fit,index=c(1,2),nsim=5)
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) y.sar <- qspec.sar(cbind(y1,y2),tau=tau,p=1) A.sim <- sar.gc.bootstrap(y.sar$qser,y.sar$fit,index=c(1,2),nsim=5)
This function extracts the spline autoregression (SAR) coefficients from an SAR model for Granger-causality analysis.
See sar.gc.bootstrap
for more details regarding the use of index
.
sar.gc.coef(fit, index = c(1, 2))
sar.gc.coef(fit, index = c(1, 2))
fit |
object of SAR model from |
index |
a pair of component indices for multiple time series
or a sequence of lags for single time series (default = |
matrix of selected SAR coefficients (number of lags by number of quantiles)
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) y.sar <- qspec.sar(cbind(y1,y2),tau=tau,p=1) A <- sar.gc.coef(y.sar$fit,index=c(1,2))
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) y.sar <- qspec.sar(cbind(y1,y2),tau=tau,p=1) A <- sar.gc.coef(y.sar$fit,index=c(1,2))
This function computes Wald test and confidence band for Granger-causality
using bootstrap samples generated by sar.gc.bootstrap()
based the spline autoregression (SAR) model of quantile series (QSER).
sar.gc.test(A, A.sim, sel.lag = NULL, sel.tau = NULL)
sar.gc.test(A, A.sim, sel.lag = NULL, sel.tau = NULL)
A |
matrix of selected SAR coefficients |
A.sim |
simulated bootstrap samples from |
sel.lag |
indices of time lags for Wald test (default = |
sel.tau |
indices of quantile levels for Wald test (default = |
a list with the following elements:
test |
list of Wald test result containing |
A.u |
matrix of upper limits of 95% confidence band of |
A.l |
matrix of lower limits of 95% confidence band of |
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) y.sar <- qspec.sar(cbind(y1,y2),tau=tau,p=1) A <- sar.gc.coef(y.sar$fit,index=c(1,2)) A.sim <- sar.gc.bootstrap(y.sar$qser,y.sar$fit,index=c(1,2),nsim=5) y.gc <- sar.gc.test(A,A.sim)
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) y.sar <- qspec.sar(cbind(y1,y2),tau=tau,p=1) A <- sar.gc.coef(y.sar$fit,index=c(1,2)) A.sim <- sar.gc.bootstrap(y.sar$qser,y.sar$fit,index=c(1,2),nsim=5) y.gc <- sar.gc.test(A,A.sim)
This function computes spline quantile discrete Fourier transform (SQDFT) for univariate or multivariate time series through trigonometric spline quantile regression.
sqdft(y, tau, c0 = 0.02, d = 4, weighted = FALSE, n.cores = 1, cl = NULL)
sqdft(y, tau, c0 = 0.02, d = 4, weighted = FALSE, n.cores = 1, cl = NULL)
y |
vector or matrix of time series (if matrix, |
tau |
sequence of quantile levels in (0,1) |
c0 |
penalty parameter |
d |
subsampling rate of quantile levels (default = 1) |
weighted |
if |
n.cores |
number of cores for parallel computing (default = 1) |
cl |
pre-existing cluster for repeated parallel computing (default = |
matrix or array of the spline quantile discrete Fourier transform of y
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) y.sqdft <- sqdft(y,tau,c0=0.02,d=4) n <- length(y) ff <- c(0:(n-1))/n sel.f <- which(ff > 0 & ff < 0.5) y.qacf <- qdft2qacf(y.sqdft) y.qper.sqrlw <- qspec.lw(y.qacf,M=5)$spec qfa.plot(ff[sel.f],tau,Re(y.qper.sqrlw[sel.f,]))
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) y.sqdft <- sqdft(y,tau,c0=0.02,d=4) n <- length(y) ff <- c(0:(n-1))/n sel.f <- which(ff > 0 & ff < 0.5) y.qacf <- qdft2qacf(y.sqdft) y.qper.sqrlw <- qspec.lw(y.qacf,M=5)$spec qfa.plot(ff[sel.f],tau,Re(y.qper.sqrlw[sel.f,]))
This function computes spline quantile regression (SQR) solution from response vector and design matrix.
It uses the FORTRAN code rqfnb.f
in the "quantreg" package with the kind permission of Dr. R. Koenker.
sqr.fit(y, X, tau, c0, d = 1, weighted = FALSE, mthreads = FALSE)
sqr.fit(y, X, tau, c0, d = 1, weighted = FALSE, mthreads = FALSE)
y |
response vector |
X |
design matrix ( |
tau |
sequence of quantile levels in (0,1) |
c0 |
penalty parameter |
d |
subsampling rate of quantile levels (default = 1) |
weighted |
if |
mthreads |
if |
A list with the following elements:
coefficients |
matrix of regression coefficients |
nit |
number of iterations |
This function computes trigonometric quantile regression (TQR) for univariate time series at a single frequency.
tqr.fit(y, f0, tau, prepared = TRUE)
tqr.fit(y, f0, tau, prepared = TRUE)
y |
vector of time series |
f0 |
frequency in [0,1) |
tau |
sequence of quantile levels in (0,1) |
prepared |
if |
object of rq()
(coefficients in $coef
)
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) fit <- tqr.fit(y,f0=0.1,tau=tau) plot(tau,fit$coef[1,],type='o',pch=0.75,xlab='QUANTILE LEVEL',ylab='TQR COEF')
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) fit <- tqr.fit(y,f0=0.1,tau=tau) plot(tau,fit$coef[1,],type='o',pch=0.75,xlab='QUANTILE LEVEL',ylab='TQR COEF')
This function computes trigonometric spline quantile regression (TSQR) for univariate time series at a single frequency.
tsqr.fit(y, f0, tau, c0, d = 1, weighted = FALSE, prepared = TRUE)
tsqr.fit(y, f0, tau, c0, d = 1, weighted = FALSE, prepared = TRUE)
y |
vector of time series |
f0 |
frequency in [0,1) |
tau |
sequence of quantile levels in (0,1) |
c0 |
penalty parameter |
d |
subsampling rate of quantile levels (default = 1) |
weighted |
if |
prepared |
if |
object of sqr.fit()
(coefficients in $coef
)
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) fit <- tqr.fit(y,f0=0.1,tau=tau) fit.sqr <- tsqr.fit(y,f0=0.1,tau=tau,c0=0.02,d=4) plot(tau,fit$coef[1,],type='p',xlab='QUANTILE LEVEL',ylab='TQR COEF') lines(tau,fit.sqr$coef[1,],type='l')
y <- stats::arima.sim(list(order=c(1,0,0), ar=0.5), n=64) tau <- seq(0.1,0.9,0.05) fit <- tqr.fit(y,f0=0.1,tau=tau) fit.sqr <- tsqr.fit(y,f0=0.1,tau=tau,c0=0.02,d=4) plot(tau,fit$coef[1,],type='p',xlab='QUANTILE LEVEL',ylab='TQR COEF') lines(tau,fit.sqr$coef[1,],type='l')