# \donttest{
#Load cyclical data (a monthly resolved long-term time series of north sea zooplankton)
data("northseaZoo")
#Define trajectories
traj <- defineTrajectories(d = dist(northseaZoo$Hellinger),
times = northseaZoo$times,
sites = northseaZoo$sites)
#Simplify it using only one site
traj <- subsetTrajectories(traj, site_selection = "NNS")
#Extract the fixed date trajectories
fdT <- extractFixedDateTrajectories(traj, cycleDuration = 1)
#Make the convergence/divergence plot
trajectoryConvergencePlot(fdT,
type = "pairwise.symmetric",
radius = 1.2,
alpha.filter = 0.05,
half.arrows.size = 2,
pointy = TRUE,
traj.names = c("Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))
#Compute the cyclical shifts (this takes a bit of time)
CS <- cycleShifts(traj, cycleDuration = 1)
#Obtain an average cyclical shift for each month (this is not automated by ecotraj,
#since many ways to do it can be justified). Here we obtain it as the slope of the regression
#line of cyclical shifts (y) on the corresponding time scale (x).
averageCS <- integer(0)
for (i in unique(CS$dateCS)){
CSmonth <- CS[CS$dateCS==i,]
model <- lm(CSmonth$cyclicalShift~CSmonth$timeScale)
averageCS <- c(averageCS,model$coefficients[2])
}
#Add the average cyclical shifts to the plot
cycleShiftArrows(averageCS, radius = 1.2)
# }
Run the code above in your browser using DataLab