Find the proportion of local minima/maxima common to both time series and compute its significance via Monte Carlo randomizations
peaks (t1, t2, nrands = 0, type = 1, quiet = FALSE)
time series 1 in matrix format (n
rows x 2 columns). The first column
should contain the time steps and the second column should contain the values.
If t1
is a column vector instead of a matrix, then it will be automatically
converted to a matrix with column 1 corresponding to a time index ranging
from 1 to the length of t1
time series 2 in matrix format (n
rows x 2 columns). The first column should contain the time
steps and the second column should contain the values. If t2
is a column
vector instead of a matrix, then it will be automatically converted to matrix
with column 1 corresponding to a time index ranging from 1 to the length of t2
.
number of randomizations. Default is 0
.
Randomization method. The type=1
method randomly shuffles each time series,
thus destroying both the autocorrelation structure of each time series and their
cross-correlation. The type=2
method shifts each time series by a random amount,
thus preserving the autocorrelation structure but destroying the cross-correlation
between the time series (Purves and Law 2002). Default is type=1
Suppress progress bar when set to TRUE
. Default is FALSE
Returns a named list containing:
p-value computed by randomly shuffling both time series nrands
times
proportion of local minima/maxima common to both time series for each randomization
proportion of local minima/maxima common to both time series in the observed dataset
indices of local minima/maxima common to both time series in the observed dataset
Buonaccorsi, J. P., J. S. Elkinton, S. R. Evans, and A. M. Liebhold. 2001. Measuring and testing for spatial synchrony. Ecology 82:1668-1679.
Purves, D. W., and R. Law. 2002. Fine-scale spatial structure in a grassland community: quantifying the plant's eye view. Journal of Ecology 90:121-129.
# NOT RUN {
t1=runif(100)
t2=runif(100)
(p=peaks(t1, t2))
# }
Run the code above in your browser using DataLab