if (FALSE) {
data(albatross)
ltr <- albatross[1]
## show the distances between successive relocations as a function
## of date
plotltr(ltr)
## focus on the first period
ltr <- gdltraj(ltr, as.POSIXct("2001-12-15", tz="UTC"),
as.POSIXct("2003-01-10", tz="UTC"))
plot(ltr)
## We identify places that seem to be a patch and, with locator,
## we measure approximately their size.
## The approximate patch radius can be set equal to 100 km as a first try
plotltr(ltr, "dt")
## As a first try, we could set maxt equal to 15000 seconds, i.e.
## approximately 4 hours
## calculation of the residence time
res <- residenceTime(ltr, radius = 100000, maxt=4, units="hour")
plot(res)
## There seems to be about 10 segments. Let us try the method
## of Lavielle (1999, 2005) to segment this series:
## First calculate again the residence time as the infolocs attribute
## of the trajectory
res <- residenceTime(ltr, radius = 100000, maxt=4, addinfo = TRUE, units="hour")
res
## Note that the residence time is now an attribute of the infolocs
## component of res
## Now, use the Lavielle method, with Kmax set to 2-3 times the
## "optimal" number of segments, assessed visually according
## to the recommendations of Barraquand and Benhamou (2008)
## We set the minimum number of relocations in each segment to
## 10 observations (given that the relocations were theoretically
## taken every hour, this defines a patch as a place where the animal
## stays at least 10 hours: this also defines the scale of our study)
ii <- lavielle(res, which="RT.100000", Kmax=20, Lmin=10)
## Both the graphical method and the automated method to choose
## the optimal number of segments indicate 4 segments
## (see ?lavielle for a description of these methods):
chooseseg(ii)
## We identify the 4 segments: the method of Lavielle seems to do a good
## job:
(pa <- findpath(ii, 4))
## and we plot this partition:
plot(pa, perani=FALSE)
## Now, we could try a study at a smaller scale (patch = 50km):
res <- residenceTime(ltr, radius = 50000, maxt=4, addinfo = TRUE,
units="hour")
ii <- lavielle(res, which="RT.50000", Kmax=20, Lmin=10)
## 5 segments seem a good choice:
chooseseg(ii)
## There is more noise in the residence time, but
## the partition is still pretty clear:
(pa <- findpath(ii, 5))
## show the partition:
plot(pa, perani = FALSE)
## Now try at a larger scale (patch size=250 km)
res <- residenceTime(ltr, radius = 250000, maxt=4, addinfo = TRUE,
units="hour")
ii <- lavielle(res, which="RT.250000", Kmax=15, Lmin=10)
## 5 segments seem a good choice again:
chooseseg(ii)
## There is more noise in the residence time, but
## the partition is still pretty clear:
(pa <- findpath(ii, 5))
## show the partition:
plot(pa, perani = FALSE)
}
Run the code above in your browser using DataLab