# [R-sig-Geo] spatstat: confusion about Kcross.inhom

Wed Feb 23 03:03:22 CET 2011

```Erika Mudrak asks:

>My confusion is why you get different values if you use density.ppp
>to generate an image file with either at="points" (creating a
>numeric vector of intensity values at the points) or at="pixels"
>(creating an image showing intensities at every location in a fine
>grid of the window).

The intensity estimators are different.

If 'at = "pixels"', then the algorithm computes a standard, fixed-bandwidth, kernel smoother estimate of the intensity, evaluated at a grid of pixel centres.

If 'at = "points"' then by default, leaveoneout = TRUE which means that the algorithm computes a leave-one-out estimator of the intensity. The estimate of the intensity at a particular data point x[i] is computed using only the *other* data points x[j] for j not equal to i.

If 'at="points"' and 'leaveoneout = FALSE' then the standard fixed bandwidth kernel smoother is computed.

The estimate with 'leaveoneout = TRUE' is preferable for use when calculaing the inhomogeneous K function (as explained in the paper Baddeley Moller and Waagepetersen cited in the help file).

Consider the following example, where X is a point pattern

A <- density(X, sigma=0.15, at="pixels")[X]
B <- density(X, sigma=0.15, at="points")
C <- density(X, sigma=0.15, at="points", leaveoneout=FALSE)

Then A and C should be approximately equal; C is more accurate than A, because A involves pixel approximation, as explained by Marcelino.

B and C are different; each entry of C should be larger than the corresponding entry of B; their exact relationship is complicated due to edge corrections.