This is the repository for the R package ordinalPatterns, which provides functions for the Ordinal Patterns Transformations, a symbolic representation of time series, originally proposed by Bandt and Pompe (2002, doi:10.1103/PhysRevLett.88.174102), that is able to capture the underlying time series dynamics.
This package provides efficient functions, through implementations in C++ with the Rcpp package, for the main time series transformation and their derived transformations: the Ordinal Patterns Probability Distribution, discussed in Rosso et al (2007, doi:10.1103/PhysRevLett.99.154102) and the Ordinal Patterns Transition Graph, detailed in Borges et al. (2019, doi:10.1016/j.amc.2019.06.068). Functions for extracting information theory measures from these transformations and for their visualization are also proposed.
In this new version, the ordinalpatterns package enables parallel execution via OpenMP threads. The parallel implementation was added to the "op" function in C++ to parallelize the OP computation. To perform the execution with parallel threads, it only needs the inclusion of the parameter threads=N, where N is the number of threads to execute in parallel. The default value for N is 1.
This package can be installed with devtools:
library(devtools)
devtools::install_github("labepi/ordinalpatterns")Otherwise, for a cleaner installation, this package can be installed with remotes:
library(remotes)
remotes::install_github("labepi/ordinalpatterns")# generating a synthetic time series
x <- rnorm(1000)
# computing the Ordinal Patterns Probability Distribution
xpd <- op_pd(x, D = 3, tau = 1)
# computing information theoretic metrics
# Shannon's permutation entropy
permutation_entropy(xpd$probabilities)
statistical_complexity(xpd$probabilities)
fisher_information(xpd$probabilities)