uniEWS {EWSmethods} | R Documentation |
Univariate Early Warning Signal Assessment
Description
A function for performing early warning signal (EWS) assessment on univariate time series. Both rolling and expanding window methods of EWS assessment can be performed with the assessments returned as a dataframe.
Usage
uniEWS(
data,
metrics,
method = c("expanding", "rolling"),
winsize = 50,
burn_in = 5,
threshold = 2,
tail.direction = "one.tailed",
trait = NULL
)
Arguments
data |
A dataframe where the first column is an equally spaced time vector and the second column is the time series to be assessed. |
metrics |
String vector of early warning signal metrics to be assessed. Options include: |
method |
Single string of either |
winsize |
Numeric value. If |
burn_in |
Numeric value. If |
threshold |
Numeric value of either |
tail.direction |
String of either |
trait |
A vector of numeric trait values if desired. Can be |
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. If |
EWS$cor |
Dataframe of Kendall Tau correlations. Only returned if |
Examples
#A dummy dataset of a hedgerow bird population over
#25 years where both the number of individuals and
#the average bill length has been measured.
abundance_data <- data.frame(time = seq(1:25),
abundance = rnorm(25,mean = 20),
trait = rnorm(25,mean=1,sd=0.5))
#The early warning signal metrics to compute.
ews_metrics <- c("SD","ar1","skew")
#Rolling window early warning signal assessment of
#the bird abundance.
roll_ews <- uniEWS(
data = abundance_data[,1:2],
metrics = ews_metrics,
method = "rolling",
winsize = 50)
#Expanding window early warning signal assessment of
#the bird abundance (with plotting).
exp_ews <- uniEWS(
data = abundance_data[,1:2],
metrics = ews_metrics,
method = "expanding",
burn_in = 10)
#Expanding window early warning signal assessment of
#the bird abundance incorporating the trait
#information.
ews_metrics_trait <- c("SD","ar1","trait")
trait_exp_ews <- uniEWS(
data = abundance_data[,1:2],
metrics = ews_metrics_trait,
method = "expanding",
burn_in = 10,
trait = abundance_data$trait)