spdensity computes a kernel smoothed spatial density function from a point pattern. This is essentially a slight modification of the density.ppp function from the spatstat package, which computes the spatial intensity of a point pattern.
spdensity(x, sigma = NULL, ..., weights = NULL, edge = TRUE,
varcov = NULL, at = "pixels", leaveoneout = TRUE, adjust = 1,
diggle = FALSE)Point pattern (object of class "ppp").
Standard deviation of isotropic Gaussian smoothing kernel. Either a numerical value, or a function that computes an appropriate value of sigma.
Additional arguments passed to pixellate.ppp and as.mask to determine the pixel resolution, or passed to sigma if it is a function.
Optional weights to be attached to the points. A numeric vector, numeric matrix, or an expression.
Logical flag: if TRUE, apply edge correction.
Variance-covariance matrix of anisotropic Gaussian kernel. Incompatible with sigma.
String specifying whether to compute the intensity values at a grid of pixel locations (at="pixels") or only at the points of x (at="points").
Logical value indicating whether to compute a leave-one-out estimator. Applicable only when at="points".
Optional. Adjustment factor for the smoothing parameter.
Logical. If TRUE, use Diggle's edge correction, which is more accurate but slower to compute than the correction described under Details.
This function produces an object of class im from the spatstat package, in nearly the exact same way as spatstat::density.ppp. The difference is that the values are scaled so that a true spatial density function is produced (i.e., the function integrates to 1).
Waller, L.A. and Gotway, C.A. (2005). Applied Spatial Statistics for Public Health Data. Hoboken, NJ: Wiley.
# NOT RUN {
data(grave)
contour(spdensity(grave))
# }
Run the code above in your browser using DataLab