perm_rollEWS {EWSmethods} | R Documentation |
Significance Testing of Rolling Window Early Warning Signals
Description
A function for identifying whether a warning has been generated from rolling early warning signal data using permutation tests. If a parallel connection is setup via parallel
or future
prior to usage of perm_rollEWS()
, then the function is parallelised.
Usage
perm_rollEWS(
data,
metrics,
winsize = 50,
variate = c("uni", "multi"),
perm.meth = "arima",
iter = 500
)
Arguments
data |
A dataframe where the first column is an equally spaced time vector and the remainder column are the time series to be assessed. If a two column dataframe is provided, and |
metrics |
String vector of early warning signal metrics to be assessed. For |
winsize |
Numeric value. Defines the window size of the rolling window as a percentage of the time series length. |
variate |
String. Is a |
perm.meth |
String dictating the pseudo-randomisation technique to be used. Options include: "arima" (sampled from predictions of an ARIMA model), "red.noise" (red noise process using data mean, variance and autocorrelation coef) or "sample" (sampled from observed data without replacement). |
iter |
Numeric value. The number of permutations. |
Value
A list containing up to two objects: EWS outputs through time (EWS
), and an identifier string (method
).
EWS$raw |
Dataframe of EWS measurements through time. Each metric's evolution over time is returned in individual columns. |
EWS$cor |
Dataframe of Kendall Tau correlations and permuted p-values. |
EWS$dimred.ts |
Dataframe containing the dimension reduction time series. Only returned if |
Examples
data(simTransComms)
#Permute p value for a univariate
#time series using resampling
#(data trimmed for speed)
perm_uni <- perm_rollEWS(
data = simTransComms$community1[1:10,2:3],
winsize = 75,
variate = "uni",
metrics = c("ar1", "SD", "skew"),
perm.meth = "sample",
iter = 25)
#Permute p value for a multivariate
#community using a red.noise process
#if parallelisation desired,
#this can be achieved using the
#below code
cl <- parallel::makeCluster(2)
doParallel::registerDoParallel(cl)
perm_multi <- perm_rollEWS(
data = simTransComms$community1[1:10,2:7],
winsize = 75,
variate = "multi",
metrics = c("meanAR", "maxAR", "meanSD"),
perm.meth = "red.noise",
iter = 25)
parallel::stopCluster(cl)