Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2014 Jun 27:5:510.
doi: 10.3389/fpsyg.2014.00510. eCollection 2014.

Cross-recurrence quantification analysis of categorical and continuous time series: an R package

Affiliations

Cross-recurrence quantification analysis of categorical and continuous time series: an R package

Moreno I Coco et al. Front Psychol. .

Abstract

This paper describes the R package crqa to perform cross-recurrence quantification analysis of two time series of either a categorical or continuous nature. Streams of behavioral information, from eye movements to linguistic elements, unfold over time. When two people interact, such as in conversation, they often adapt to each other, leading these behavioral levels to exhibit recurrent states. In dialog, for example, interlocutors adapt to each other by exchanging interactive cues: smiles, nods, gestures, choice of words, and so on. In order for us to capture closely the goings-on of dynamic interaction, and uncover the extent of coupling between two individuals, we need to quantify how much recurrence is taking place at these levels. Methods available in crqa would allow researchers in cognitive science to pose such questions as how much are two people recurrent at some level of analysis, what is the characteristic lag time for one person to maximally match another, or whether one person is leading another. First, we set the theoretical ground to understand the difference between "correlation" and "co-visitation" when comparing two time series, using an aggregative or cross-recurrence approach. Then, we describe more formally the principles of cross-recurrence, and show with the current package how to carry out analyses applying them. We end the paper by comparing computational efficiency, and results' consistency, of crqa R package, with the benchmark MATLAB toolbox crptoolbox (Marwan, 2013). We show perfect comparability between the two libraries on both levels.

Keywords: R library; behavioral data; cognitive dynamics; cross-recurrence analysis; methodology comparison.

PubMed Disclaimer

Figures

Figure 1
Figure 1
Two example experimental runs, in which we observe the behavior of two simple conversational “agents,” a confederate (C) and participant (S), over 1000 time steps. The confederate’s behavior is experimentally setup to amplify the occurrence of the event. P(C) in the plot reflects the raw probability that the confederate will emit the behavioral event (see Table 1). As specified in the agent’s policies, an increase in the behavioral event by the confederate should also increase it in the participant, which analyses are meant to bear out.
Figure 2
Figure 2
Data from 20 simulated interactions for each condition of the confederate’s event occurrence rate (0.05 vs. 0.25). As expected, one sees a relative increase in the event’s occurrence in agent S if it occurs in agent C.
Figure 3
Figure 3
Unfolding aggregate scores using cross correlation. Cross-correlation functions between confederate and participant agents. The high agent condition (red), reflecting the cross-correlation between C and S agents at different time lags or shifts (scale: step increments), shows maximal variance accounted for at lag −1, C leading S by one time step (as set in the simulation). Smoothed profiles generated with ggplot2 in R, with stat_smooth which uses standard error to define the width of the lines.
Figure 4
Figure 4
Example cross recurrence plots (CRPs) of two sample runs of the simulated data. Left shows a high condition run, right shows a low condition run. Points reflect relative moments in time where C and S are revisiting event states (=1), whereas 0’s (non-events) do not produce points on the plot. Three black lines define the approximate location of the lag calculations described in the text (from −5 to +5). The middle black line is the line of coincidence (LOC), where lag = 0. Though difficult to see in this plot, the points appear shifted slightly upwards (lagged +1), indicative of C leading S. This pattern becomes more evident in Figure 5, when calculating percentage recurrence over these diagonals.
Figure 5
Figure 5
By calculating the rate of points on diagonals around the LOC (left side), we obtain a diagonal-wise recurrence that reflects the relative co-visitation, as a function of lag (right side). The line superimposed on both panels shows the approximate region over which percentages are calculated. Like cross-correlation we get a maximization at −1, reflecting C driving S. However, the difference between the conditions is larger, proportional to the relative rate of occurrence. Recurrence does not count non-events (0’s), so the y-axis levels will be determined by the frequency of the events in the time series (1’s). Smoothed profiles (on the right) were generated with ggplot2 in R, with stat_smooth which uses standard error to define the width of the lines.
Figure 6
Figure 6
A basic sketch of how recurrence is constructed from one time series (top left). The time series is lagged (by 10), copied (3 times), and overlaid with itself (top right). If we use 3 dimensions (copies), then it is possible to visualize this reconstructed phase space (bottom left). By drawing a radius of a given size around parts of this reconstructed phase space (thick line, bottom left), one can determine when recurrence is taking place. The time indices of these recurrence points can be used to construct the recurrence plot (bottom right). Cross recurrence is done in almost exactly the same way, except two time series are used.
Figure 7
Figure 7
Data available in crqa. Eye-movement responses of dyads (speakers and listeners) engaged in dialog from Richardson and Dale (2005) (left panel, RDts1, RDts2). Body-movement intensity of the interlocutors engaged in a conversation from Paxton and Dale (2013) (right panel, leftmov, rightmov). In the bottom row of the figure, we illustrate the concept of recurrence in categorical and continuous time series, and the role played by the radius parameter when the series are not lagged.
Figure 8
Figure 8
Diagonal-wise recurrence profile for two eye-movement series (RDts1, RDts2) taken from Richardson and Dale (2005).
Figure 9
Figure 9
Window cross-recurrence of the two eye-movement series (RDts1, RDts2) from Richardson and Dale (2005).
Figure 10
Figure 10
Recurrence Plot of the two eye-movement series (RDts1, RDts2) from Richardson and Dale (2005). The recurrent points are marked with blue color, whereas the non-recurrent points are left blank. The values obtained on the measures for this plot are: REC = 12.52; DET = 98.95; Lmax = 124; L = 11.3; ENTR = 3.2; LAM = 99.7; TT = 20.6. Usually, these values are interpreted relatively, by comparing one condition to another condition in an experiment. In general, DET will be higher than REC, with DET often quite high (90% or higher) and REC considerably lower (10% or less), so 12% would be considered relatively high.
Figure 11
Figure 11
Phi-coefficient plot of a particular object for the two eye-movement series (RDts1, RDts2) from Richardson and Dale (2005).
Figure 12
Figure 12
Elapsed user time to extract CRQ measures on simulated dichotomous time series of increasing lengths using crqa in R and crqtoolbox in MATLAB. Means over 20 iterations are shown as lines. The programming language of the library is identified using line type.

References

    1. Bakeman R. (1997). Observing Interaction: an Introduction to Sequential Analysis. Cambridge: Cambridge University Press; 10.1017/CBO9780511527685 - DOI
    1. Bakeman R., Quera V. (2011). Sequential Analysis and Observational Methods for the Behavioral Sciences. Cambridge: Cambridge University Press; 10.1017/CBO9781139017343 - DOI
    1. Balasubramaniam R., Riley M., Turvey M. (2000). Specificity of postural sway to the demands of a precision task. Gait Posture 11, 12–24 10.1016/S0966-6362(99)00051-X - DOI - PubMed
    1. Barbosa A., Déchaine R., Vatikiotis-Bateson E., Yehia H. (2012). Quantifying time-varying coordination of multimodal speech signals using correlation map analysis. J. Acoust. Soc. Am. 131, 2162 10.1121/1.3682040 - DOI - PubMed
    1. Bargh J., Chartrand T. (1999). The unbearable automaticity of being. Am. Psychol. 54, 462–479 10.1037/0003-066X.54.7.462 - DOI

LinkOut - more resources