#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)
Run the code above in your browser using DataLab