(href ) was sequentially reduced in 0.10 increments (0.9 href,
0.8 href, 0.7 href, …0.1 href ). This rule-based had hoc was the
smallest increment of href that: 1) resulted in a contiguous
rather than disjoint 95% kernel home-range polygon, and
2) contained no lacuna within the home range."
Thanks
Anna
Best,library(spatstat) library(raster) data(bei)
#### bandwidth (sigma) functions
bw.scott <- function(X) {
stopifnot(spatstat::is.ppp(X))
n <- spatstat::npoints(X)
sdx <- sqrt(stats::var(X$x))
sdy <- sqrt(stats::var(X$y))
return(c(sdx, sdy) * n^(-1/6))
}
bw.stoyan <- function(X, co = 0.15) {
stopifnot(spatstat::is.ppp(X))
n <- spatstat::npoints(X)
W <- spatstat::as.owin(X)
a <- spatstat::area.owin(W)
stoyan <- co/sqrt(5 * n/a)
return(stoyan)
}
bw.geometry <- function(X, f = 1/4) {
X <- spatstat::as.owin(X)
g <- spatstat::distcdf(X)
r <- with(g, .x)
Fr <- with(g, .y)
iopt <- min(which(Fr >= f))
return(r[iopt])
}
bw.likelihood <- function(X, srange = NULL, ns = 16) {
stopifnot(spatstat::is.ppp(X))
if (!is.null(srange))
spatstat::check.range(srange) else {
nnd <- spatstat::nndist(X)
srange <- c(min(nnd[nnd > 0]), spatstat::diameter(spatstat::as.owin(X))/2)
}
sigma <- exp(seq(log(srange[1]), log(srange[2]), length = ns))
cv <- numeric(ns)
for (i in 1:ns) {
si <- sigma[i]
lamx <- spatstat::density.ppp(X, sigma = si, at = "points", leaveoneout = TRUE)
lam <- spatstat::density.ppp(X, sigma = si)
cv[i] <- sum(log(lamx)) - spatstat::integral.im(lam)
}
result <- spatstat::bw.optim(cv, sigma, iopt = which.max(cv), criterion = "Likelihood Cross-Validation")
return(result)
}
# Create 1st and 2nd order isotropic density estimates and plot
d <- stack(raster(spatstat::density.ppp(bei, sigma = bw.diggle(bei))))
d <- addLayer(d, raster(spatstat::density.ppp(bei, sigma = bw.stoyan(bei))))
d <- addLayer(d, raster(spatstat::density.ppp(bei, sigma = bw.scott(bei))))
d <- addLayer(d, raster(spatstat::density.ppp(bei, sigma = bw.likelihood(bei))))
d <- addLayer(d, raster(spatstat::density.ppp(bei, sigma = bw.geometry(bei))))
names(d) <- c("Diggle", "Stoyan", "Likelihood", "Scott", "Geometry")
plot(d)
########## END CODE ##########
References
Berman, M. and Diggle, P. (1989) Estimating weighted integrals of the second-order intensity of a spatial point process. Journal of the Royal Statistical Society, series B 51, 81-92.
Loader, C. (1999)Local Regression and Likelihood. Springer, New York.
Scott, D.W. (1992) Multivariate Density Estimation. Theory, Practice and Visualization. New York, Wiley.
Stoyan, D. and Stoyan, H. (1995) Fractals, random shapes and point fields: methods of geometrical statistics. John Wiley and Sons.