This is the accompanying R package specsimfts
for the paper:
Rubin and Panaretos (2020). "Spectral Simulation of Functional Time Series". arXiv:2007.08458
The package contains all the methods introduced in the aformentioned paper including all the presented examples as demos (see below) that are easy to use and modify by functional time series (FTS) practitioners.
Run this code in your R console (install first the package devtools
if not installed yet):
# install.packages("devtools")
library("devtools")
install_github("tomasrubin/specsimfts")
For the background to the simulation methods refer to the article [1].
The packages includes four simulation approaches (see below) depending how the functional time series dynamics is specified. Each approach includes a function to simulate a FTS sample and another one to calculate the theoretical lagged autocovariance operator. The numerical calculation of these operators is performed by integrating the spectral density operators through the inverse formula. While the simulation methods are generally fast, the inverse formula integration can be slower.
CKL_simulate
, CKL_covlagh_operator
,demo_CKL
.spec_density_simulate
, spec_density_covlagh_operator
,demo_plain_spec_density
.filter_simulate
, filter_covlagh_operator
,demo_FARFIMA_as_filter
, demo_FARFIMA_as_filter_SVD
,demo_custom_filter
, demo_custom_filter_SVD
.FARFIMA_test_stationarity
, FARFIMA_simulate
, FARFIMA_covlagh_operator
,demo_FARMA
, demo_FARMA_SVD
,demo_FARFIMA_spec_vs_hybrid
.The functions arguments and outputs are documented within the package. Run for example ?CKL_simulate
to see the documentation.
You can run the demo files using the built-in R command demo()
or alternatively download this GitHub repository and view the *.R
files stored in the folder /demo/
.
The simulation is the fastest and simplest if the FTS dynamics is defined directly through the eigendecomposition of its spectral density operators. The simulation method then essentially mimics the Cramer-Karhunen-Loeve expansion.
library("specsimfts")
demo("demo_CKL")
If the eigendecomposition of spectral density operators is not available but we still define the FTS dynamics directly by its spectral density operator at each frequency, the spectral density operator needs to be discretised and decomposed by the SVD algorithm at each frequency. This method allows to simulate any dynamics defined by the spectral density operator but scales badly in terms of computational time as the discretisation resolution increases.
library("specsimfts")
demo("demo_plain_spec_density")
The FARFIMA(1,0.2,0) process scrutinised in Example 4.2 can be written as a filtered white noise process while having a direct formula for the frequency response function because of the special structure of the autoregressive operator. The demo file demo_FARFIMA_as_filter.R
contains this implementation together with benefiting from the analytic eigendecomposition of the innovation white noise processes.
library("specsimfts")
demo("demo_FARFIMA_as_filter")
If the innovation white noise processes does not admit analytically known eigendecomposition it can be calculated by the SVD algorithm, inspect the demo below.
library("specsimfts")
demo("demo_FARFIMA_as_filter_SVD")
As an additional demo file we provide with an extra example where the frequency response function is quite generally defined using operations including rank-one-tensors, kernel integral operators, antiderivatives, and identity operators. See the comments in the demo file. The white noise admits Brownian motion covariance with known analytic eigendecomposition
library("specsimfts")
demo("demo_custom_filter")
or which can be numerically calculated by the SVD algorithm
library("specsimfts")
demo("demo_custom_filter_SVD")
The FARMA(4,3) process, being a special case of the FARFIMA(p,d,q) process with d=0, scrutinized in Example 4.3 in the paper is included as a demo file demo_FARMA.R
. The code is easy to modify and allows to include an arbitrary number of autoregressive and moving average operators defined as integral operators with given kernels, and to set the fractional integration parameter d in the interval (-0.5, 0.5).
library("specsimfts")
demo("demo_FARMA")
While the above example uses the explicite finite-rank specification of the innovation white noise, the FAR(FI)MA processes can be also simulated with an arbitrary innovation noise whose eigendecomposition is numerically calculated by the SVD algorithm.
library("specsimfts")
demo("demo_FARMA_SVD")
Besides the fully spectral method which can be a bit slower for FARFIMA processes with non-trivial autoregressive part, we have also proposed a hybrid simulation method. The demo file below shows how to run the two approaches and compares their running times.
library("specsimfts")
demo("demo_FARFIMA_spec_vs_hybrid")
Individuals are free to use the codes for the purpose academic research, provided it is properly acknowledged and [1] is cited. For any other use, permission must first be arranged with the author. Unless otherwise specified, the author of the codes is Tomas Rubin (tomas.rubin@gmail.com). Please contact me if you find errors in the codes or if you have feature requests.
[1] Rubin and Panaretos (2020). "Spectral Simulation of Functional Time Series". arXiv:2007.08458
Tomas Rubin
tomas.rubin@gmail.com
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.