Skip to content
Prev 15538 / 29559 Next

error: subscript out of bounds using getverticeshr

Hello Melanie


[snip]
Hard to correct without any reproducible example. This kind of error 
occurs when the required isopleth falls outside the grid used for the 
kernel estimation. For example, this error occurs in the example below 
(just copy and paste):

data(puechabonsp)
loc <- puechabonsp$relocs
ud <- kernelUD(loc[,1], grid=5)
getverticeshr(ud, 30)

The solution is here to increase the size of the grid. In the example 
below, the problem is due to a misspecified grid:

data(puechabonsp)
loc <- puechabonsp$relocs
ud <- kernelUD(loc[,1], grid=5)
gr <- ud[[1]]
ud2 <- kernelUD(loc[,1], grid=gr)
getverticeshr(ud2)

The solution is here to specify another grid. In your case I do not know 
what can cause the problem. Just a guess: you estimate the smoothing 
parameter using the ad hoc method (href). If the distribution of your 
relocations is very different from the expected bivariate normal 
distribution, the home-range contour might be far from the set of 
relocations, and most of the estimated UD might be outside the grid. 
Just an example of this error for a too large href:

df <- data.frame(x=c(rnorm(3), rnorm(3, 10000), rnorm(3, 5000)), 
y=c(rnorm(3), rnorm(3), rnorm(3, 5000)))
ps <- SpatialPoints(df)
plot(ps)
kud <- kernelUD(ps)
image(kud)
ver <- getverticeshr(kud)

If this is the case with your data, try to increase the value of extent 
or to set a smaller value of href in kernelUD (increasing the parameter 
grid won't help here). For this example, using extent=1 allows to 
perform the calculation:

kud <- kernelUD(ps, h="href", extent=1)
image(kud)
ver <- getverticeshr(kud)

Although h="href" is clearly a poor choice in this case.

HTH,

Cl?ment Calenge.