View source: R/wccFindDyadParam.R
| wccFindDyadParam | R Documentation |
This function calculates the difference between surrogate and actual dyads for a range of possible arguments to wccCalc and wccPeakPick.
wccFindDyadParam(inArray1=NA, inArray2=NA, wMaxvector=c(50), tMaxvector=c(50),
wIncvector=c(1), tIncvector=c(1), Lsizevector=c(8), pspanvector=c(.25), type="Max",
nSurrogates=NA, samplespersecond=1,
method=c("c", "cumr", "cumc", "r"), embedD=9, ...)
inArray1 |
An N by T matrix of numeric values representing N timeseries of length T. These are the first set of time series which are randomly paired with timeseries from ‘inArray2’ and on which windowed cross correlation are calculated. Must be of the same order N by T as ‘inArray2’. Note that the only difference between ‘inArray1’ and ‘inArray2’ is which is treated as positive lag and which is negative lag in |
inArray2 |
An N by T matrix of numeric values representing N timeseries of length T. These are the second set of time series which are randomly paired with timeseries from ‘inArray1’ and on which windowed cross correlation are calculated. Must be of the same order N by T as ‘inArray1’. When ‘inArray2’ is leading ‘inArray1’, the peak correlation closest to zero in positive in |
wMaxvector |
A numeric vector indicating the number of samples in a window for each test (default=c(50)). This must be greater or equal to 5 samples. It is recommended that wMax be greater than 15. |
tMaxvector |
A numeric vector indicating the maximum number of samples to lag the windows for each test (default=c(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. |
wIncvector |
A numeric vector indicating the number of samples incremented between successive windows for each test (default=c(1)). If the sample rate is very high and the time series is long, wInc may be increased. However, |
tIncvector |
A numeric vector indicating the number of samples incremented between successive lags for each test (default=c(1)). If the sample rate is high and the maximum lag is high then tInc may be increased. However, |
Lsizevector |
A numeric vector indicating the width required for a peak to be identified by |
pspanvector |
A numeric vector indicating the amount of smoothing applied by the loess function within |
type |
A character string vector indicating whether a maximum, ‘Max’, or minimum, ‘Min’, should be detected by |
nSurrogates |
A numeric indicating the number of surrogates to generate (default=NA). If there are N timeseries in ‘inArray1’, then the maximum number of unique surrogates that can be generated is N*(N-1)/2 |
samplespersecond |
A numeric indicating the sampling rate of the time series (default=1). This will determine the units of the first and second derivative aggregate statistics. |
method |
Backend passed through to |
embedD |
A numeric indicating the embedding dimension passed to |
... |
Reserved for the deprecated |
This function iterates over vectors of possible argument values given to wccCalc and wccPeakPick and for each combination of arguments returns the difference between the surrogate dyadic null hypothesis distribution and the true distribution of each of the statistics returned by wccAggregate. The intended use of this function is to explore the space of possible argument values using a small hold-out set of dyadic timeseries in order to inform the selection of parameters to use for the full dataset. It is recommended that between 10 and 20 dyadic timeseries be used as the hold-out set to input to this function. The two arguments ‘wMax’ and ‘tMax’ are the most commonly explored parameters since they tend to have the most impact on results.
Results from combinations of parameters can be visualized using the wccHeatmap function. For any particular hypothesis, one or more aggregate statistics may be most useful in assessing the association between a dyad's time series. Thus, one may wish to focus in on that statistic when choosing parameters. wccHeatmapwMaxtMax allows the visualization of the effect of selecting the ‘wMax’ and ‘tMax’ parameters on the statistic of interest.
Note that surrogate and real dyads will be calculated for all combinations of parameters in the argument vectors. Thus, if one wishes to explore the effects of 8 choices of ‘wMax’ and 8 choices of ‘tMax’, a total of 64 surrogate analyses will be run. If one uses a holdout set of 20 and asks for 100 surrogates, this will result in 7,680 calls to wccAggregate. Such an exploration of the parameter space can take hours to run. Add to that 2 choices of ‘wInc’ and 2 choices of ‘tInc’ and you may be talking about days of processing. Be careful when choosing how many combinations to explore at one time.
Returns a dataframe with some of the columns from the wccAggregate function, some columns with redefined meanings, and some new columns.
For each aggregated statistic a column giving the proportion of real dyads' statistics are greater than .95 or less than .05 of the values in the surrogate statistics distribution. For each aggregated statistic a column giving the two sided Kolmogorov-Smirnov Test probabilities comparing the surrogate and real dyad distributions. These probabilities are those returned by a call to ks.test() with alternative="two.sided". For each aggregated statistic a column giving the quantile difference scores for the difference between the surrogate distribution and the real distribution of dyadic timeseries. These quantile differences are the mean of the difference between calls to quantile() with probs=seq(.1,.9, by=.1) for the real dyads and the surrogate dyads. Each row in the dataframe presents the results from one combination of chosen parameters.
The returned data frame is defined as follows.
| ‘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’ | The proportion of the real data that are either greater than 95% less than 5% of the surrogate distribution of means 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’ | The proportion of the real data that are either greater than 95% less than 5% of the surrogate distribution of 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’ | The proportion of the real data that are either greater than 95% less than 5% of the surrogate distribution of mean of the Fischer's Z transform of all values in the matrix returned by wccCalc. |
| ‘totalVar’ | The proportion of the real data that are either greater than 95% less than 5% of the surrogate distribution of variance of the Fischer's Z transform of all values in the matrix returned by wccCalc . |
| ‘zeroLagMean’ | The proportion of the real data that are either greater than 95% less than 5% of the surrogate distribution of mean of the Fischer's Z transform of all values in the zero lag column of the matrix returned by wccCalc. |
| ‘zeroLagVar’ | The proportion of the real data that are either greater than 95% less than 5% of the surrogate distribution of variance of the Fischer's Z transform of all values in the zero lag column of the matrix returned by wccCalc. |
| ‘lagMean’ | The proportion of the real data that are either greater than 95% less than 5% of the surrogate distribution of mean of the lag vector returned by wccPeakPick. |
| ‘lagVar’ | The proportion of the real data that are either greater than 95% less than 5% of the surrogate distribution of variance of the lag vector returned by wccPeakPick. |
| ‘dlagMean’ | The proportion of the real data that are either greater than 95% less than 5% of the surrogate distribution of mean of the first derivative of the lag vector returned by wccPeakPick. |
| ‘dlagVar’ | The proportion of the real data that are either greater than 95% less than 5% of the surrogate distribution of variance of the first derivative of the lag vector returned by wccPeakPick. |
| ‘d2lagMean’ | The proportion of the real data that are either greater than 95% less than 5% of the surrogate distribution of mean of the second derivative of the lag vector returned by wccPeakPick. |
| ‘d2lagVar’ | The proportion of the real data that are either greater than 95% less than 5% of the surrogate distribution of variance of the second derivative of the lag vector returned by wccPeakPick. |
| ‘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. |
| ‘totalMeanKS’ | The probability of the two tailed Kolmogorov-Smirnov test for the difference between the surrogate distribution and real dyad distribution of the mean of the Fischer's Z transform of all values in the matrix returned by wccCalc. |
| ‘totalVarKS’ | The probability of the two tailed Kolmogorov-Smirnov test for the difference between the surrogate distribution and real dyad distribution of the variance of the Fischer's Z transform of all values in the matrix returned by wccCalc . |
| ‘zeroLagMean’ | The probability of the two tailed Kolmogorov-Smirnov test for the difference between the surrogate distribution and real dyad distribution of the mean of the Fischer's Z transform of all values in the zero lag column of the matrix returned by wccCalc. |
| ‘zeroLagVarKS’ | The probability of the two tailed Kolmogorov-Smirnov test for the difference between the surrogate distribution and real dyad distribution of the variance of the Fischer's Z transform of all values in the zero lag column of the matrix returned by wccCalc. |
| ‘lagMeanKS’ | The probability of the two tailed Kolmogorov-Smirnov test for the difference between the surrogate distribution and real dyad distribution of the mean of the lag vector returned by wccPeakPick. |
| ‘lagVarKS’ | The probability of the two tailed Kolmogorov-Smirnov test for the difference between the surrogate distribution and real dyad distribution of the variance of the lag vector returned by wccPeakPick. |
| ‘dlagMeanKS’ | The probability of the two tailed Kolmogorov-Smirnov test for the difference between the surrogate distribution and real dyad distribution of the mean of the first derivative of the lag vector returned by wccPeakPick. |
| ‘dlagVarKS’ | The probability of the two tailed Kolmogorov-Smirnov test for the difference between the surrogate distribution and real dyad distribution of the variance of the first derivative of the lag vector returned by wccPeakPick. |
| ‘d2lagMeanKS’ | The probability of the two tailed Kolmogorov-Smirnov test for the difference between the surrogate distribution and real dyad distribution of the mean of the second derivative of the lag vector returned by wccPeakPick. |
| ‘d2lagVarKS’ | The probability of the two tailed Kolmogorov-Smirnov test for the difference between the surrogate distribution and real dyad distribution of the variance of the second derivative of the lag vector returned by wccPeakPick. |
| ‘maxMeanQdiff’ | The quantile difference (using deciles) between the surrogate and the real distribution of the 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. |
| ‘maxVarQdiff’ | The quantile difference (using deciles) between the surrogate and the real distribution of the 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. |
| ‘totalMeanQdiff’ | The quantile difference (using deciles) between the surrogate and the real distribution of the mean of the Fischer's Z transform of all values in the matrix returned by wccCalc. |
| ‘totalVarQdiff’ | The quantile difference (using deciles) between the surrogate and the real distribution of the variance of the Fischer's Z transform of all values in the matrix returned by wccCalc . |
| ‘zeroLagMeanQdiff’ | The quantile difference (using deciles) between the surrogate and the real distribution of the mean of the Fischer's Z transform of all values in the zero lag column of the matrix returned by wccCalc. |
| ‘zeroLagVarQdiff’ | The quantile difference (using deciles) between the surrogate and the real distribution of the variance of the Fischer's Z transform of all values in the zero lag column of the matrix returned by wccCalc. |
| ‘lagMeanQdiff’ | The quantile difference (using deciles) between the surrogate and the real distribution of the mean of the lag vector returned by wccPeakPick. |
| ‘lagVarQdiff’ | The quantile difference (using deciles) between the surrogate and the real distribution of the variance of the lag vector returned by wccPeakPick. |
| ‘dlagMeanQdiff’ | The quantile difference (using deciles) between the surrogate and the real distribution of the mean of the first derivative of the lag vector returned by wccPeakPick. |
| ‘dlagVarQdiff’ | The quantile difference (using deciles) between the surrogate and the real distribution of the variance of the first derivative of the lag vector returned by wccPeakPick. |
| ‘d2lagMeanQdiff’ | The quantile difference (using deciles) between the surrogate and the real distribution of the mean of the second derivative of the lag vector returned by wccPeakPick. |
| ‘d2lagVarQdiff’ | The quantile difference (using deciles) between the surrogate and the real distribution of the variance of the second derivative of the lag vector returned by wccPeakPick. |
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.
William J. Conover (1971). Practical Nonparametric Statistics. New York: John Wiley & Sons. Pages 295-301 (one-sample Kolmogorov test), 309-314 (two-sample Smirnov test).
wccHeatmap visualizes results selected aggregated statistics for combinations of parameters. See wccAggregate for definitions of the statistics that are compared between surrogate and real dyads. See ks.test for definition of the two tailed Kolmogorov-Smirnov Test.
# Create two arrays of timeseries with dyadic dependence
array1 <- matrix(NA, nrow=10, ncol=500)
array2 <- matrix(NA, nrow=10, ncol=500)
for(i in 1:10) {
array1[i,] <- sin(c(1:500)/runif(1, min=5, max=20)) + rnorm(500, mean=0, sd=.5)
array2[i,] <- array1[i,] + rnorm(500, mean=0, sd=.5)
}
# Select parameters to explore
wMaxVec <- c(50,100)
tMaxVec <- c(25,50)
wccFindDyadParam(inArray1=array1, inArray2=array2, wMaxvector=wMaxVec, tMaxvector=tMaxVec,
nSurrogates=30, samplespersecond=1, method="c")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.