## 7.3 (auto-) Recurrence Quantification Analysis

There are several packages which can perform (C)RQA analysis, we’ll use `crqa`

because it can perform both continuous and categorical analyses. If you only have continuous data, you migh be better off using package `nonlinearTseries`

, in this course we will only use package `crqa`

.

Package

`crqa()`

was designed to run categorical Cross-Recurrence Quantification Analysis (see Coco & Dale (2014) and for R code see appendices in Coco & Dale (2013)). We can trick it to run auto-RQA by providing the same timeseries for `ts1`

and `ts2`

and setting the parameter `side`

to either `"upper"`

or `"lower"`

- Perform an RQA on the reconstructed state space of the Lorenz system.
- You’ll need a radius (also called: threshold) in order to decide which points are close together (recurrent).
`crqa`

provides a function which will automatically select the best parameter settings:`optimizeParam()`

- Best way to ensure you are using the same parameters in each function is to create some lists with parameter settings (check the
`crqa`

manual to figure out what these parameters mean):

- You’ll need a radius (also called: threshold) in order to decide which points are close together (recurrent).

```
# General settings for `crqa()`
par0 <- list(rescale = 1,
normalize = 0,
mindiagline = 2,
minvertline = 2,
tw = 0,
whiteline = FALSE,
recpt = FALSE,
side = "lower",
checkl = list(do = FALSE, thrshd = 3, datatype = "categorical",pad = TRUE)
)
# Settings for `optimizeParam()`
par <- list(lgM = 20, steps = seq(1, 6, 1),
radiusspan = 100, radiussample = 40,
normalize = par0$normalize,
rescale = par0$rescale,
mindiagline = par0$mindiagline, minvertline = par0$minvertline,
tw = par0$tw,
whiteline = par0$whiteline,
recpt = par0$recpt,
fnnpercent = 10, typeami = "mindip")
```

- Get the optimal parameters using a radius which will give us 2%-5% recurrent points.

`ans <- optimizeParam(ts1 = lx, ts2 = lx, par = par, min.rec = 2, max.rec = 5)`

- Run the RQA analysis using the same settings with which the parameters were found.

```
crqaOutput <- crqa(ts1 = lx, ts2 = lx,
delay = ans$delay,
embed = ans$emddim,
radius = ans$radius,
normalize = par0$normalize,
rescale = par0$rescale,
mindiagline = par0$mindiagline, minvertline = par0$minvertline,
tw = par0$tw,
whiteline = par0$whiteline,
recpt = par0$recpt,
side = par0$side, checkl = par0$checkl
)
```

- The output of
`crqa`

is a list with recurrence measures, the last entry is the recurrence plot. It is represented as a so-called`sparse-matrix`

.- This representation severely decreases the amount of memory occupied by the recurrence matrix. It is basically a list of indices of cells that contain a \(1\). The \(0\) do not need to be stored.
- In order to plot this matrix you could use
`image()`

, but this does not produce the recurrence plot as they are usually displayed, the y-axis needs to be flipped. - We created a function which will take as input the list output of
`crqa`

, which wil be used to plot the recurrence matrix. If you have sourced the`nlRtsa`

functions you can call`plotRP.crqa(crqaOutput)`

.