Description Usage Arguments Value References See Also Examples
View source: R/filter_simulate.R
Simulate functional time series sample when the dynamics is defined as a filtered white noise through the white noise covariance operator and the filter is given by its frequency response function Theta.
| 1 2 3 4 5 6 7 8 9 10 11 | 
| theta | The frequency response operator Theta(omega) of the filter used for the definition of filtered white noise. A function of two variables,  | 
| t_max | Time horizon to be simulated. Must be an even number, otherwise it is increased by one. | 
| n_grid | Number of grid points (spatial resolution) of the discretisation of [0,1] where the FTS is to be simulated. | 
| n_pc | The number of eigenfunctions of sigma to be used for the simulation. Setting n_pc=n_grid is recommended as there is hardly any computational gain when n_pc is smaller. In case the sigma is defined as finite rank operator (through lists  | 
| seed_number | The random seed inicialization for the simulation. The value  | 
| 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  | 
| include_freq_zero | If set  | 
functional time series sample, matrix of size (n_grid,t_max)
Rubin, Panaretos. Simulation of stationary functional time series with given spectral density. arXiv, 2020
filter_covlagh_operator, rank_one_tensor, kernel_operator
| 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 | # 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
# simulate in the spectral domain
fts_x <- filter_simulate(theta, t_max, n_grid, sigma=sigma)
# # Alternatively simulate with the known eigendecomposition of sigma
# fts_x <- filter_simulate(theta, t_max, n_grid, sigma_eigenfunctions = sigma_eigenfunctions, sigma_eigenvalues=sigma_eigenvalues)
# plot the first curve
plot(fts_x[,1], type='l')
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.