Skip to contents

Computes standard Recurrence Quantification Analysis (RQA) measures from a multivariate state-space embedding, separately for each participant.

RQA characterises the temporal organisation of a dynamical system by examining how often and in what patterns the system revisits previous states. The function accepts output from make_statespace() directly — each row of the embedded matrix is treated as a point in the reconstructed state space.

When multiple subseries exist per participant (e.g., from overnight breaks detected by resample_timeseries()), RQA is first computed within each subseries and then averaged to yield participant-level estimates.

Usage

compute_rqa(
  data,
  r = 1,
  min_diag = 2L,
  min_vert = 2L,
  participant_col = "ID",
  series_col = "Series_ID",
  time_col = "time",
  verbose = TRUE
)

Arguments

data

An experdyn_statespace object returned by make_statespace(), or a data frame containing lagged columns named *_lag0, *_lag1, etc.

r

[numeric(1): 1.0]
Euclidean distance threshold for the recurrence matrix. Data are z-scored within each subseries before distances are computed, so r is on a standardised scale.

min_diag

[integer(1): 2]
Minimum diagonal line length included in DET, L, and ENTR calculations.

min_vert

[integer(1): 2]
Minimum vertical line length included in LAM and TT calculations.

participant_col

[character(1): "ID"]
Participant identifier column.

series_col

[character(1): "Series_ID"]
Subseries identifier column.

time_col

[character(1): "time"]
Optional time column used for ordering within subseries.

verbose

[logical(1): TRUE]
If TRUE, prints a short completion summary.

Value

An object of class experdyn_rqa — a named list with:

ElementDescription
participant_rqaOne row per participant with cross-series mean RQA measures.
series_rqaOne row per participant-subseries with per-series RQA measures.
recurrence_dataSparse data frame of recurrence point coordinates for plotting.
rMatching tolerance used.
min_diagMinimum diagonal line length used.
min_vertMinimum vertical line length used.

RQA measures (columns in participant_rqa and series_rqa):

MeasureDescription
RRRecurrence Rate — proportion of recurrent points.
DETDeterminism — proportion of recurrences forming diagonal lines ≥ min_diag.
LMean diagonal line length.
LmaxLongest diagonal line.
ENTRShannon entropy of diagonal line length distribution.
LAMLaminarity — proportion of recurrences forming vertical lines ≥ min_vert.
TTTrapping Time — mean vertical line length.
VmaxLongest vertical line.

See also

Examples

set.seed(1)
n <- 30
t_obs <- as.POSIXct("2025-01-01 09:00:00") +
  cumsum(sample(60 * c(60, 90), n, replace = TRUE))
df <- data.frame(
  time        = t_obs,
  Component_1 = cumsum(rnorm(n)),
  Component_2 = cumsum(rnorm(n))
)
rs  <- resample_timeseries(df, time_col = "time", verbose = FALSE, plot = FALSE)
ss  <- make_statespace(rs)
rqa <- compute_rqa(ss, r = 1.2, verbose = FALSE)
rqa
#> ===== Recurrence Quantification Analysis =====
#>   Tolerance (r)          : 1.200
#>   Min diagonal (min_diag): 2
#>   Min vertical (min_vert): 2
#>   Participants           : 1
#>   Series                 : 1
#> 
#>   ID n_series n_series_valid    RR   DET     L Lmax  ENTR   LAM   TT Vmax
#>  All        1              1 0.109 0.754 2.875    7 1.127 0.582 2.84    6
#> 
#>   Per-series results : use `$series_rqa`
#>   Recurrence data    : use `$recurrence_data` (for custom plots)
#> ===============================================