# [AniMov] kernel UD

Clément Calenge calenge at biomserv.univ-lyon1.fr
Wed Jul 18 10:18:36 CEST 2007

```Hi Leslie,

I also send a copy of this mail to animove, as this may be of use for

> 1) Could there be any theoretical problems fitting a home range
> with a grid 10 times the area needed? Meaning, if your points are
> contained within a 500m area and you use a grid 10 times the size.

There could be indeed. In fact, the resulting home range will be made of
zero or one pixel, depending on the position of the center of the pixel
relative to the relocations. The UD is indeed evaluated at the center of
the pixels of the grid.

If the center of the pixel is far from the relocations, then the UD at
this point will be very low (and probably roughly equal to zero). Thus
the corresponding grid of values will be a grid of zeros. No UD can be
estimated in this case. For example:

data(puechabon)

## Creates the grid: too coarse
pts <- data.frame(x=c(500000,1000000), y=c(3150000,3170000))
asc <- ascgen(pts, nrcol=10)
image(asc)
points(puechabon\$locs[,c("X","Y")], col="red")

## estimates the UD
kud <- kernelUD(puechabon\$locs[,c("X","Y")],
puechabon\$locs\$Name, grid=asc)
image(kud)
summary(c(kud[[1]]\$UD))

On the other hand, if, by luck, the center of the pixel is close to the
relocations, then the UD estimated at this point will not be equal to
zero, and the UD will be non zero only at this point (as this sole pixel
is the minimum area containing 95% of the volume under the UD). For Example:

## shifts the above grid so that the center of one pixel falls close to
## the relocations

attr(asc, "xll") <- attr(asc, "xll") + 33038
attr(asc, "yll") <- attr(asc, "yll") - 45875.8

## estimates the UD
kud <- kernelUD(puechabon\$locs[,c("X","Y")],
puechabon\$locs\$Name, grid=asc)
image(kud)

> 2) In the past you have helped me with some code that estimates the
> density values and then uses the udvol function to take the values
> contained
> within the 95% contour.
>
> udvol<-getvolumeUD(ud)
> ## replaces the values upper than 95% with NA
> gr <- lapply(gr, function(x) {x[x>95] <- NA;return(x)})
>
> At this point, I would like to export the density values (not the
> volume values) contained within
> the 95% contour. what is the easiest way of doing this?

## Estimate the UD and the volume
data(puechabon)
ud <- kernelUD(puechabon\$locs[,c("X","Y")], puechabon\$locs\$Name)
udvol <- getvolumeUD(ud)

## computes res
res <- lapply(1:length(ud), function(i) {
uu <- ud[[i]]\$UD
uu[udvol[[i]]\$UD>95] <- NA
uu <- getascattr(ud[[i]]\$UD,uu)
return(uu)
})

## Displays the results
par(mfrow=c(2,2), mar=c(0,0,0,0))
lapply(res, function(x) {
image(x, axes=FALSE)
box()
})

> 3) Sometimes we get VERY small values for our grid cells. (e-45) Is
> there any way of
> "standardizing" this data (multipying it by 1000000) before exporting?

Actually, the data are already standardized so that the volume under the
UD is equal to 1. Of course, it is always possible to multiply these
values by 1000000 before exporting:

for (i in 1:length(ud)) {
ud[[i]]\$UD <- ud[[i]]\$UD*1000000
}

Hope this helps,

Clément Calenge.

--
Clément CALENGE
LBBE - UMR CNRS 5558 - Université Claude Bernard Lyon 1 - FRANCE
tel. (+33) 04.72.43.27.57
fax. (+33) 04.72.43.13.88

```