# density.ppp

##### Kernel Smoothed Intensity of Point Pattern

Compute a kernel smoothed intensity function from a point pattern.

##### Usage

```
## S3 method for class 'ppp':
density(x, sigma, \dots, weights, edge=TRUE, varcov=NULL)
```

##### Arguments

- x
- Point pattern (object of class
`"ppp"`

). - sigma
- Standard deviation of isotropic Gaussian smoothing kernel.
- weights
- Optional vector of weights to be attached to the points. May include negative values.
- ...
- Arguments passed to
`as.mask`

to determine the pixel resolution. - edge
- Logical flag: if
`TRUE`

, apply edge correction. - varcov
- Variance-covariance matrix of anisotropic Gaussian kernel.
Incompatible with
`sigma`

.

##### Details

This is a method for the generic function `density`

.

It computes a fixed-bandwidth kernel estimate
(Diggle, 1985) of the intensity function of the point process
that generated the point pattern `x`

.
By default it computes the convolution of the
isotropic Gaussian kernel of standard deviation `sigma`

with point masses at each of the data points in `x`

.
Each point has unit weight, unless the argument `weights`

is
given (it should be a numeric vector; weights can be negative or zero).

If `edge=TRUE`

, the intensity estimate is corrected for
edge effect bias by dividing it by the convolution of the
Gaussian kernel with the window of observation.

Instead of the isotropic Gaussian kernel with standard deviation
`sigma`

, the smoothing kernel may be chosen to be any Gaussian
kernel, by giving the variance-covariance matrix `varcov`

.
The arguments `sigma`

and `varcov`

are incompatible.
Also `sigma`

may be a vector of length 2 giving the
standard deviations of two independent Gaussian coordinates,
thus equivalent to `varcov = diag(sigma^2)`

.
Computation is performed using the Fast Fourier Transform.
Accuracy depends on the pixel resolution, controlled by the arguments
`...`

passed to `as.mask`

.

To perform spatial interpolation of values that were observed
at the points of a point pattern, use `smooth.ppp`

.

For adaptive nonparametric estimation, see `adaptive.density`

.

##### Value

- A pixel image (object of class
`"im"`

). Pixel values are estimated intensity values, expressed inpoints per unit area .

##### Note

This function is often misunderstood.

The result of `density.ppp`

is not a spatial smoothing
of the marks or weights attached to the point pattern.
To perform spatial interpolation of values that were observed
at the points of a point pattern, use `smooth.ppp`

.

The result of `density.ppp`

is not a probability density.
It is an estimate of the *intensity function* of the
point process that generated the point pattern data.
Intensity is the expected number of random points
per unit area.
The units of intensity are `density.ppp`

.
The integral of the intensity function over a spatial region gives the
expected number of points falling in this region.

Inspecting an estimate of the intensity function is usually the first step in exploring a spatial point pattern dataset. For more explanation, see the workshop notes (Baddeley, 2008) or Diggle (2003).

##### References

Baddeley, A. (2008) Analysing spatial point patterns in R.
Workshop notes. CSIRO online technical publication.
URL: `www.csiro.au/resources/pf16h.html`

Diggle, P.J. (1985)
A kernel method for smoothing point process data.
*Applied Statistics* (Journal of the Royal Statistical Society,
Series C) **34** (1985) 138--147.

Diggle, P.J. (2003)
*Statistical analysis of spatial point patterns*,
Second edition. Arnold.

##### See Also

##### Examples

```
data(cells)
Z <- density.ppp(cells, 0.05)
plot(Z)
```

*Documentation reproduced from package spatstat, version 1.15-2, License: GPL (>= 2)*