Description Usage Arguments Value References See Also Examples
View source: R/FARFIMA_covlagh_operator.R
Numerically calculate the lag-h covariance operators for FARFIMA(p,d,q) process. The calculation is done by numerically integrating the inverse formula, i.e. the spectral density multiplied by exp(-1i*lag*omega). If the process has non-degenerate autoregressive part, the evaluation of the spectral density requires matrix inversion at each frequency. The function is very slow for large or even moderate n_grid
.
1 | FARFIMA_covlagh_operator(FARFIMA_pars, lag, n_grid, n_grid_freq = 500)
|
FARFIMA_pars |
The list of the parameters for the FARFIMA(p,d,q) process. Must contain fields: (i) |
lag |
The lag of the autocovariance to evaluate. |
n_grid |
Number of grid points (spatial resolution) of the discretisation of [0,1]^2 for the operator kernel to evaluate. |
n_grid_freq |
The grid points for the spectral density to evaluate at. Partition of [0,pi]. |
lag-h autocovariance operator, matrix of size (n_grid,n_grid)
Rubin, Panaretos. Simulation of stationary functional time series with given spectral density. arXiv, 2020
FARFIMA_simulate
, FARFIMA_test_stationarity
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | # (i) fractional integration
fractional_d <- 0 # in the open interval (-0.5, 0.5), positive number means long-range dependence
# (ii) autoregressive operators
operators_ar <- list(
function(x,y){ 0.3*sin(x-y) },
function(x,y){ 0.3*cos(x-y) },
function(x,y){ 0.3*sin(2*x) },
function(x,y){ 0.3*cos(y) }
)
# operators_ar <- list() # use empty list for degenerate AR part
# (iii) moving average kernels
# you can put here arbitrary long list of operators
operators_ma <- list(
function(x,y){ x+y },
function(x,y){ x },
function(x,y){ y }
)
# operators_ma <- list() # use empty list for degenerate MA part
# (iv-b) covariance of the inovation defined through eigenvalues and eigenfunctions
# you can put here arbitrary long lists but their lenghts should match
sigma_eigenvalues <- c(1, 0.6, 0.3, 0.1, 0.1, 0.1, 0.05, 0.05, 0.05, 0.05)
sigma_eigenfunctions <- list(
function(x){ sin(2*pi*x) },
function(x){ cos(2*pi*x) },
function(x){ sin(4*pi*x) },
function(x){ cos(4*pi*x) },
function(x){ sin(6*pi*x) },
function(x){ cos(6*pi*x) },
function(x){ sin(8*pi*x) },
function(x){ cos(8*pi*x) },
function(x){ sin(10*pi*x) },
function(x){ cos(10*pi*x) }
)
# # (iv-c) innovation covariance operator (Brownian motion)
# sigma_eigenvalues <- function(n) { 1/((n-0.5)*pi)^2 }
# sigma_eigenfunctions <- function(n,x) { sqrt(2)*sin((n-0.5)*pi*x) }
# put the parameters into one list
FARFIMA_pars <- list(fractional_d=fractional_d, operators_ar=operators_ar, operators_ma=operators_ma, sigma_eigenvalues=sigma_eigenvalues,sigma_eigenfunctions=sigma_eigenfunctions)
# # (iv-a) Alternatively, define the kernel of the white noise innovation.
# sigma <- function(x,y) { pmin(x,y) } # Brownian motion
# FARFIMA_pars <- list(fractional_d=fractional_d,operators_ar=operators_ar,operators_ma=operators_ma, sigma=sigma)
if (FARFIMA_test_stationarity(FARFIMA_pars)){
# calculate the lag-h autocovariance kernel
lag <- 1 # change here to evaluate different lag-h autocovariance operator. put "lag <- 0" for lag-0 covariance operator
covlagh <- FARFIMA_covlagh_operator(FARFIMA_pars, lag, n_grid)
# surface plot the covlagh
persp(covlagh)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.