crqa crqa logo

Unidimensional and Multidimensional Methods for Recurrence Quantification Analysis

The crqa R package allows users to conduct a wide range of recurrence-based analyses on single (e.g., auto-recurrence) and multivariate time series (e.g., multidimensional cross-recurrence quantification), examine coupling properties underlying leader-follower relationships (i.e., diagonal-profile methods), as well as track the evolution of recurrence rate over the time course (i.e., windowed methods).

Installation

# You can install the latest version of crqa on CRAN by running:
install.packages("crqa")

# Or for the development version from GitHub:
# install.packages("devtools")
# devtools::install_github("morenococo/crqa")
install.packages("crqa", repos = c('https://morenococo.r-universe.dev', 'https://cloud.r-project.org'))

What's new in v2.1.0

Usage

crqa comes with bundled datasets that can be used to explore the different functions.

data(crqa) # loads eyemovement, handmovement, and text datasets

Auto-recurrence on a categorical time-series

Run auto-recurrence on a nursery rhyme (“The wheels on the bus”, 120 words):

delay = 1; embed = 1; rescale = 0; radius = 0.0001
normalize = 0; mindiagline = 2; minvertline = 2
tw = 1; whiteline = FALSE; recpt = FALSE
side = “both”; method = “rqa”; metric = “euclidean”
datatype = “categorical”

ans = crqa(ts1 = text, ts2 = text,
           delay = delay, embed = embed, rescale = rescale,
           radius = radius, normalize = normalize,
           mindiagline = mindiagline, minvertline = minvertline,
           tw = tw, whiteline = whiteline, recpt = recpt,
           side = side, method = method, metric = metric,
           datatype = datatype)

print(ans[!names(ans) %in% “RP”])

Cross-recurrence on a categorical time-series

Eye-tracking data from a joint task: 2,000 observations of six screen locations looked at by a narrator and a listener.

narrator = eyemovement$narrator
listener  = eyemovement$listener

delay = 1; embed = 1; rescale = 0; radius = 0.001
normalize = 0; mindiagline = 2; minvertline = 2
tw = 0; whiteline = FALSE; recpt = FALSE; side = “both”
method = “crqa”; metric = “euclidean”; datatype = “categorical”

ans = crqa(ts1 = narrator, ts2 = listener,
           delay = delay, embed = embed, rescale = rescale,
           radius = radius, normalize = normalize,
           mindiagline = mindiagline, minvertline = minvertline,
           tw = tw, whiteline = whiteline, recpt = recpt,
           side = side, method = method, metric = metric,
           datatype = datatype)

print(ans[!names(ans) %in% “RP”])

Diagonal cross-recurrence profile

Extract the diagonal cross-recurrence profile (DCRP) to quantify leader–follower dynamics across a range of lags:

timecourse = round(seq(-3300, 3300, 33) / 1000, digits = 2)

res = drpfromts(ts1 = narrator, ts2 = listener,
                windowsize = 100,
                delay = 1, embed = 1, rescale = 0,
                radius = 0.001, normalize = 0,
                mindiagline = 2, minvertline = 2,
                tw = 0, whiteline = FALSE, recpt = FALSE,
                side = “both”, method = “crqa”,
                metric = “euclidean”, datatype = “categorical”)

profile = res$profile * 100  # recurrence rate in %

plot(timecourse, profile, type = “l”, lwd = 2.5,
     xlab = “Lag (seconds)”, ylab = “Recurrence Rate %”)

Multidimensional cross-recurrence quantification analysis

Hand-movement data from a LEGO joint construction task (5,799 observations, two position channels per person):

P1 = cbind(handmovement$P1_TT_d, handmovement$P1_TT_n)
P2 = cbind(handmovement$P2_TT_d, handmovement$P2_TT_n)

delay = 5; embed = 2; rescale = 0; radius = 0.1
normalize = 0; mindiagline = 10; minvertline = 10
tw = 0; whiteline = FALSE; recpt = FALSE; side = “both”
method = “mdcrqa”; metric = “euclidean”; datatype = “continuous”

ans = crqa(ts1 = P1, ts2 = P2,
           delay = delay, embed = embed, rescale = rescale,
           radius = radius, normalize = normalize,
           mindiagline = mindiagline, minvertline = minvertline,
           tw = tw, whiteline = whiteline, recpt = recpt,
           side = side, method = method, metric = metric,
           datatype = datatype)

print(ans[!names(ans) %in% “RP”])

Authors

Contributors