Learn R Programming

synchrony (version 0.3.8)

peaks: Find the proportion of local minima/maxima common to both time series and compute its significance via Monte Carlo randomizations

Description

Find the proportion of local minima/maxima common to both time series and compute its significance via Monte Carlo randomizations

Usage

peaks (t1, t2, nrands = 0, type = 1, quiet = FALSE)

Arguments

t1

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

t2

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.

nrands

number of randomizations. Default is 0.

type

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

quiet

Suppress progress bar when set to TRUE. Default is FALSE

Value

Returns a named list containing:

pval

p-value computed by randomly shuffling both time series nrands times

rands

proportion of local minima/maxima common to both time series for each randomization

obs

proportion of local minima/maxima common to both time series in the observed dataset

index

indices of local minima/maxima common to both time series in the observed dataset

References

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.

Examples

Run this code
# NOT RUN {
t1=runif(100)
t2=runif(100)
(p=peaks(t1, t2))

# }

Run the code above in your browser using DataLab