## S3 method for class 'ppp':
density(x, sigma, \dots,
weights, edge=TRUE, varcov=NULL,
at="pixels", leaveoneout=TRUE)
"ppp"
).as.mask
to determine
the pixel resolution.TRUE
, apply edge correction.sigma
.at="pixels"
) or
only at the points of x
(at="points"
).at="points"
."im"
).
Pixel values are estimated intensity values,
expressed in If at="points"
, the result is a numeric vector
of length equal to the number of points in x
.
Values are estimated intensity values at the points of x
.
In either case, the return value has attributes
"sigma"
and "varcov"
which report the smoothing
bandwidth that was used.
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)
.
Thus the intensity value at a point $u$ is $$\hat\lambda(u) = e(u) \sum_i k(x_i - u) w_i$$ where $k$ is the Gaussian smoothing kernel, $e(u)$ is an edge correction factor, and $x_i$ are the weights.
By default the intensity values are
computed at every location $u$ in a fine grid,
and are returned as a pixel image.
Computation is performed using the Fast Fourier Transform.
Accuracy depends on the pixel resolution, controlled by the arguments
...
passed to as.mask
.
If at="points"
, the intensity values are computed
to high accuracy at the points of x
only. Computation is
performed by directly evaluating and summing the Gaussian kernel
contributions without discretising the data. The result is a numeric
vector giving the density values.
The intensity value at a point $x_i$ is
$$\hat\lambda(x_i) = e(x_i) \sum_j k(x_j - x_i) w_i$$
If leaveoneout=TRUE
(the default), then the sum in the equation
is taken over all $j$ not equal to $i$,
so that the intensity value at a
data point is the sum of kernel contributions from
all other data points.
If leaveoneout=FALSE
then the sum is taken over all $j$,
so that the intensity value at a data point includes a contribution
from the same point.
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
.
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.
smooth.ppp
,
adaptive.density
,
ppp.object
,
im.object
data(cells)
Z <- density(cells, 0.05)
plot(Z)
density(cells, 0.05, at="points")
Run the code above in your browser using DataLab