[R-sig-Geo] error: subscript out of bounds using getverticeshr
Clement Calenge
clement.calenge at oncfs.gouv.fr
Sun Jul 8 17:59:11 CEST 2012
Hello Melanie
[snip]
> #data is now in proper format to calculate kernelUD for each ID
> #result is a list of elements of class estUD (1 for each replicate)
> kud<-kernelUD(t62spdf,h="href",grid=50,same4all=TRUE,kern=c("bivnorm"))
> kudw<-kernelUD(t62spdfw,h="href",grid=50,same4all=TRUE,kern=c("bivnorm"))
> #get the vertices for the 95% and 50% contours
> ver95<- getverticeshr(kud, lev = 95) ###########here is where the error
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.
--
Clément CALENGE
Cellule d'appui à l'analyse de données
Direction des Etudes et de la Recherche
Office national de la chasse et de la faune sauvage
Saint Benoist - 78610 Auffargis
tel. (33) 01.30.46.54.14
More information about the R-sig-Geo
mailing list