# NOT RUN {
data(puechabon)
loc <- puechabon$locs[, c("X", "Y")]
id <- puechabon$locs[, "Name"]
## Estimation of UD for the four animals
(ud <- kernelUD(loc, id))
image(ud) ## Note that the contours
## corresponds to values of probability density
udvol <- getvolumeUD(ud)
image(udvol)
## Here, the contour corresponds to the
## home ranges estimated at different probability
## levels (i.e. the contour 90 corresponds to the 90 percent
## kernel home-range)
## udvol describes, for each cell of the grid,
## the smaller home-range to which it belongs
## Calculation of the 95 percent home range
ver <- getverticeshr(ud, 95)
elev <- getkasc(puechabon$kasc, "Elevation") # Map of the area
image(elev)
plot(ver, add=TRUE)
legend(696500, 3166000, legend = names(ver), fill = rainbow(4))
## Example of estimation using LSCV
udbis <- kernelUD(loc, id, h = "LSCV")
image(udbis)
## Compare the estimation with ad hoc and LSCV method
## for the smoothing parameter
(cuicui1 <- kernel.area(loc, id)) ## ad hoc
plot(cuicui1)
(cuicui2 <- kernel.area(loc, id, h = "LSCV")) ## LSCV
plot(cuicui2)
## Diagnostic of the cross-validation
plotLSCV(udbis)
## Use of the same4all argument: the same grid
## is used for all animals
udbis <- kernelUD(loc, id, same4all = TRUE)
image(udbis)
## Estimation of the UD on a map
## (e.g. for subsequent analyses on habitat selection)
elev <- getkasc(puechabon$kasc, "Elevation")
opar <- par(mfrow = c(2, 2), mar = c(0, 0, 2, 0))
cont <- getcontour(elev)
for (i in 1:length(udbis)) {
image(elev, main = names(udbis)[i], axes = FALSE)
points(udbis[[i]]$locs, pch = 21, bg = "white", col = "black")
}
## Measures the UD in each pixel of the map
udbis <- kernelUD(loc, id, grid = elev)
opar <- par(mfrow = c(2, 2), mar = c(0, 0, 2, 0))
for (i in 1:length(udbis)) {
image(udbis[[i]]$UD, main = names(udbis)[i], axes = FALSE)
box()
polygon(cont[, 2:3])
}
par(opar)
## Estimation of the UD with a list of objects of class "asc" passed as
## argument grid (useful for large datasets)
## For example, consider the following limits:
lim <- rbind(c(697901,701061,3160198,3162604),
c(698936,701089,3159969,3162518),
c(698461,701928,3157362,3160427),
c(698265,701369,3157219,3162661))
gro <- lapply(1:4, function(i) {
subsetmap(elev, xlim = lim[i,1:2], ylim=lim[i,3:4])
})
names(gro) <- levels(id)
## show the data:
opar <- par(mfrow=c(2,2), mar=c(0.1,0.1,2,0.1))
lapply(1:4, function(i) {
image(gro[[i]], main=names(gro)[i], axes=FALSE)
points(loc[id==names(gro)[i],])
box()
})
gro
## The map has been subset to fit the relocations.
## Now, estimate the UD:
ud.one.per.grid <- kernelUD(loc, id, grid = gro)
image(ud.one.per.grid)
## The UD can then be matched to habitat maps
# }
Run the code above in your browser using DataLab