# Spatstat package and Spatial point process: How to estimate the density when computing the inhomogeneous K-function?

http://www.inside-r.org/packages/cran/spatstat/docs/Kinhom

Here we see that to get the inhomogeneous K-function, we can either use a kernel density approximation method with small bandwidth to estimate the first-order density, or using a polynomial in x and y directions and estimate in a parametric way.

Which one is better at what kind of situation?

Thanks

## 1 Answer

It is not really possible to give a generic answer to this. If you have a parametric model for the intensity that you really trust you should obviously go for that, but that is rarely the case. If you use kernel smoothing you should probably use the leave-one-out estimator which is the default if no intensity is given. This avoids some bias. In either case it is very important that the intensity isn't very small at one of your data locations since reciprocal intensities are used for weighting.

• well, the leave-one-out estimator in R produces an error if your study region is complicated (as opposed to regular shapes, like a rectangle). Does this matter a lot? if there are a like a hundred points in your study area then I am not sure if to excluded the data point at which it is being estimated is that important.. – Wudanao Oct 1 '15 at 21:12
• Well X <- unmark(spruces) has 134 points, and the intensity values of lam2 <- density(X, leaveoneout=FALSE, at="points") are 10-50% larger than lam <- density(X, leaveoneout=TRUE, at="points") so it does have some effect. You can also see a difference directly on plots of Kinhom in the two cases. Try plot(Kinhom(X, leaveoneout=FALSE), iso-theo~r) followed by plot(Kinhom(X), iso-theo~r, col = 2, add = TRUE) – Ege Rubak Oct 2 '15 at 20:13