| wccPlot | R Documentation |
This function plots a Windowed Cross Correlation heatmap.
wccPlot(inSeries1=NA, inSeries2=NA, startwindow=1, endwindow=200, wMax=50, tMax=50,
wInc=1, tInc=1, Lsize=8, pspan=.25, type="Max", samplespersecond=1,
method=c("c", "cumr", "cumc", "r"), ...)
inSeries1 |
A vector of numeric values. This is the first time series on which windowed cross correlation is calculated. When |
inSeries2 |
A vector of numeric values. This is the second time series on which windowed cross correlation is calculated. Must be of the same length as |
startwindow |
A numeric value specifying the first window to plot (default=1). Windows are plotted as vertical stripes in the heatmap and the elapsed time of this window is |
endwindow |
A numeric value specifying the last window to plot (default=200). |
wMax |
A numeric indicating the number of samples in a window (default=50). This must be greater or equal to 5 samples. It is recommended that wMax be greater than 15. |
tMax |
The maximum number of samples to lag the windows (default=50). The cross correlation is calculated for windows that are time lagged against each other, allowing for processes than require some time to evolve. For instance, if the two time series are from motion capture of two individuals conversing with one another, the speaker's movements are likely to occur prior to the responses of the listener. tMax should be set to be greater than the number of samples that represents the maximum time lag that is likely to occur. |
wInc |
The number of samples incremented between successive windows (default=1). This is most often set to 1. If the sample rate is very high and the time series is long, wInc may be increased. However, |
tInc |
The number of samples incremented between successive lags (default=1). This is most often set to 1. If the sample rate is high and the maximum lag is high then tInc may be increased. However, |
Lsize |
An integer specifying the width required for a peak to be identified by |
pspan |
A numeric specifying the amount of smoothing applied by the loess function within |
type |
A character string indicating whether a maximum, ‘Max’, or minimum, ‘Min’, should be detected by |
samplespersecond |
A numeric indicating the sampling rate of the time series. This will determine the units of the first derivative aggregate statistics. (default=1) |
method |
Backend passed through to |
... |
Reserved for the deprecated |
This function runs wccCalc and wccPeakPick using the arguments passed in and plots a heatmap of a selected section of windows. The vertical axis is labeled with the lags in the units of seconds. Each calculated window is plotted as a vertical slice of the heat map and correlations near 1 are plotted in yellow and correlations near -1 are plotted in red. Lags of inSeries1 are plotted as positive and lags of inSeries2 are plotted as negative lags. The horizontal black line in the middle of the plot represents a lag of zero. Thus, if a feature in inSeries1 occurs prior to a similar feature in inSeries2, there will be a positive correlation shown at a negative lag, i.e., below the horizontal zero lag line. The result of wccPeakPick is overlayed as a black line that traces the peak correlation closest to a lag of zero. The horizontal axis is labeled with the elapsed time to the right edge of two windows when they are at zero lag.
It is recommended that the plot includes no more than 1000 windows since if a large number of windows are plotted, the resulting heatmap will overwrite one window with the next window. Other considerations include whether the interval of time of interest is near the beginning or end of the timeseries. The elapsed time associated with the first window will be tMax*tInc*samplespersecond. Thus an elapsed time of 0 will never occur. It is recommended that the startwindow and endwindow be set to bracket a sample of the timeseries that is of interest to the researcher. If endwindow - startwindow is about 500, a balance between sensitivity to nonstationarity and plotting resolution is achieved.
Returns nothing.
Boker, S. M., Rotondo, J. L., Xu, M., & King, K. (2002). Windowed cross-correlation and peak picking for the analysis of variability in the association between behavioral time series. Psychological methods, 7(3), 338.
wccCalc and wccPeakPick for the calculation of the wccCalc matrix and wccPeakPick timeseries that are used by this function.
#Create a windowed cross correlation plot for two simulated time series with a phase offset
tSeries1 <- sin(c(1:1000)/10) + rnorm(1000, mean=0, sd=.5)
tSeries2 <- sin(1+c(1:1000)/10) + rnorm(1000, mean=0, sd=.5)
wccPlot(inSeries1=tSeries1, inSeries2=tSeries2, startwindow=1, endwindow=500,
wMax=100, tMax=100, wInc=1, tInc=1, Lsize=8, pspan=.25, type="Max",
samplespersecond=10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.