wccAggregate: wccAggregate

View source: R/wccAggregate.R

wccAggregateR Documentation

wccAggregate

Description

This function runs wccCalc and peakpicking on a pair of time series and returns aggregate statistics.

Usage

wccAggregate(inSeries1=NA, inSeries2=NA, wMax=50, tMax=50, wInc=1, tInc=1, Lsize=8,
     pspan=.25, type="Max", samplespersecond=1,
     method=c("c", "cumr", "cumc", "r"), embedD=9, ...)

Arguments

inSeries1

A vector of numeric values. This is the first time series on which windowed cross correlation is calculated. When inSeries1 is leading inSeries2, the peak correlation closest to zero in negative in wccPlot. Note that inSeries1 must be of the same length as inSeries2. Note that the only difference between inSeries1 and inSeries2 is which is treated as positive lag and which is negative lag in wccPlot.

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 inSeries1. When inSeries2 is leading inSeries1, the peak correlation closest to zero in positive in wccPlot.

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, wccCalc's maximum sensitivity to nonstationary change in the time series occurs when wInc is 1.

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, wccCalc's maximum sensitivity to changes in lags occurs when the tInc is set to 1.

Lsize

An integer specifying the width required for a peak to be identified by wccPeakPick (default=8). An Lsize that is too small may find spurious peaks that are just noise, whereas an Lsize that is too large may miss actual peaks.

pspan

A numeric specifying the amount of smoothing applied by the loess function within wccPeakPick (default=.25).

type

A character string indicating whether a maximum, ‘Max’, or minimum, ‘Min’, should be detected by wccPeakPick (default="Max").

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 wccCalc: "c" (default, original compiled windcross), "r" (original pure-R loop), "cumc" (cumulative-sum C backend), or "cumr" (cumulative-sum pure-R reference). See wccCalc for details and the missing-data caveat for the cum* methods.

embedD

A numeric indicating the embedding dimension passed to GLLAEmbed to calculate derivatives of the peak picking lag timeseries. The default (9) will provide a medium smooth at the cost of some loss of resolution in the timing of jumps in the second derivative. The smallest legal value is 5, which provides less smoothing and the best time resolution. If your sampling rate is low, then a smaller value of embedD is useful, while if your sampling rate is high, a larger value of embedD will provide better noise rejection by smoothing.

...

Reserved for the deprecated windcross=TRUE/FALSE argument, mapped to method="c" / method="r" with a warning.

Details

wccAggregate is a wrapper for the wccCalc and wccPeakpick functions. The returns from these two function calls are then aggregated into 10 different statistics representing characteristics of wccCalc and wccPeakpick for the pair of input time series. wccAggregate also must be called with a filename in the savefile argument prior to calling wccPlot so that the raw results can be plotted. The wccAggregate function returns a single row dataframe so that it can be called repeatedly by the wccSurrogateDyad function to create a distribution of surrogate Windowed Cross Correlation results. The arguments are also saved in this dataframe so that the wccFindDyadParam function can explore the space of arguments to find appropriate values from a hold-out set of timeseries to then be used to calculate surrogate distributions for the full data set.

Value

wccAggregate returns a data frame with one row and the following columns:

‘wMax’ The value of wMax in the argument passed to wccCalc.
‘tMax’ The value of tMax in the argument passed to wccCalc.
‘wInc’ The value of wInc in the argument passed to wccCalc.
‘tInc’ The value of tInc in the argument passed to wccCalc.
‘Lsize’ The value of Lsize in the argument passed to wccPeakPick.
‘pspan’ The value of pspan in the argument passed to wccPeakPick.
‘type’ The value of type as a numeric translation of the type argument passed to wccPeakPick. This is +1 when type = ‘Max’ and -1 when type = ‘Min’.
‘samples’ Length of the time series inSeries1 and inSeries2
‘windows’ The number of windows returned by wccCalc.
‘pctMissing’ Proportion of missing values in the matrix returned by wccCalc.
‘pctMissingWindows’ Proportion of windows (i.e., rows) in the matrix returned by wccCalc that include at least one missing value.
‘maxMean’ Mean of the Fischer's Z transform of the maximum correlation vector returned returned by wccPeakPick. Note that if type=‘Min’ then this value is the Fischer's Z transform of the minimum correlation vector.
‘maxVar’ Variance of the Fischer's Z transform of the maximum correlation vector returned returned by wccPeakPick. Note that if type=‘Min’ then this value is the Fischer's Z transform of the minimum correlation vector.
‘totalMean’ Mean of the Fischer's Z transform of all values in the matrix returned by wccCalc.
‘totalVar’ Variance of the Fischer's Z transform of all values in the matrix returned by wccCalc .
‘zeroLagMean’ Mean of the Fischer's Z transform of all values in the zero lag column of the matrix returned by wccCalc.
‘zeroLagVar’ Variance of the Fischer's Z transform of all values in the zero lag column of the matrix returned by wccCalc.
‘lagMean’ Mean of the lag vector returned by wccPeakPick.
‘lagVar’ Variance of the lag vector returned by wccPeakPick.
‘dlagMean’ Mean of the first derivative of the lag vector returned by wccPeakPick.
‘dlagVar’ Variance of the first derivative of the lag vector returned by wccPeakPick.
‘d2lagMean’ Mean of the second derivative of the lag vector returned by wccPeakPick.
‘d2lagVar’ Variance of the second derivative of the lag vector returned by wccPeakPick.
‘elapsedSeconds’ Total elapsed seconds required to perform all calculations and function calls.

References

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.

See Also

wccCalc, wccPeakPick, loess.

Examples

#Calculate aggregated statistics for windowed cross correlation between two time series
tSeries1 <- sin(c(1:1000)/10) + rnorm(1000, mean=0, sd=.5)
tSeries2 <- sin(c(1:1000)/15) + rnorm(1000, mean=0, sd=.5)
wccAggregate(inSeries1=tSeries1, inSeries2=tSeries2, wMax=50, tMax=50, wInc=1, tInc=1,
     Lsize=8, pspan=.25, type="Max", samplespersecond=10, method="c")


wcc documentation built on July 14, 2026, 5:07 p.m.