Description Usage Arguments Value References See Also Examples
View source: R/filter_covlagh_operator.R
Numerically calculate the lag-h covariance operators for functional time series dynamics defined as a filter of a white noise. The calculation is done by numerically integrating the inverse formula, i.e. the spectral density multiplied by exp(-1i*lag*omega)
1 2 3 4 5 6 7 8 9 |
theta |
The frequency response operator Theta(omega) of the filter used for the definition of filtered white noise. A function of two variables, |
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. |
sigma |
The covariance operator of the white noise innovation. A function of two variables, |
sigma_eigenvalues |
Alternatively, you can define the white noise innovation covariance operator through its eigendecomposition, in which case supply the arguments |
sigma_eigenfunctions |
See |
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
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 | # define the white noise covariance operator (Brownian motion)
sigma <- function(x,y) { pmin(x,y) }
# # Alternatively defined the sigma covariance through its eigendecomposition, and supply it to the function 'filter_simulate'
# sigma_eigenvalues <- function(n) { 1/((n-0.5)*pi)^2 }
# sigma_eigenfunctions <- function(n,x) { sqrt(2)*sin((n-0.5)*pi*x) }
# # Alternatively, define the innovation covariance as low-rank (through a list)
# 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) }
# )
# define filter
theta <- function(omega,f){
2*f+
1i*rev(f) +
omega*cumsum(f)/length(f) +
rank_one_tensor( function(x){sin(x)}, function(x){exp(x)}, f ) +
kernel_operator( function(x,y){sin(omega+x+2*y)}, f )
}
# simulation setting
t_max <- 1000
n_grid <- 101
# evaluation setting
lag <- 1 # change here to evaluate different lag-h autocovariance operator. put "lag <- 0" for lag-0 covariance operator
n_grid <- 101
# numerically evaluate lag-h autocovariance operator - WARNING: this takes a minute or so
lag <- 0
covlagh <- filter_covlagh_operator(theta, lag, n_grid, sigma=sigma)
# # Alternatively simulate with the known eigendecomposition of sigma
# covlagh <- filter_covlagh_operator(theta, lag, n_grid, sigma_eigenfunctions = sigma_eigenfunctions, sigma_eigenvalues=sigma_eigenvalues)
# visualise as a surface plot
persp(covlagh)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.