Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

densityfun

Kernel Estimate of Intensity as a Spatial Function


Description

Compute a kernel estimate of intensity for a point pattern, and return the result as a function of spatial location.

Usage

densityfun(X, ...)

## S3 method for class 'ppp'
densityfun(X, sigma = NULL, ...,
                        weights = NULL, edge = TRUE, diggle = FALSE)

Arguments

X

Point pattern (object of class "ppp").

sigma

Smoothing bandwidth, or bandwidth selection function, passed to density.ppp.

...

Additional arguments passed to density.ppp.

weights

Optional vector of weights associated with the points of X.

edge,diggle

Logical arguments controlling the edge correction. Arguments passed to density.ppp.

Details

The commands densityfun and density both perform kernel estimation of the intensity of a point pattern. The difference is that density returns a pixel image, containing the estimated intensity values at a grid of locations, while densityfun returns a function(x,y) which can be used to compute the intensity estimate at any spatial locations with coordinates x,y. For purposes such as model-fitting it is more accurate to use densityfun.

Value

A function with arguments x,y,drop. The function also belongs to the class "densityfun" which has methods for print and as.im. It also belongs to the class "funxy" which has methods for plot, contour and persp.

Using the result of densityfun

If f <- densityfun(X), where X is a two-dimensional point pattern, the resulting object f is a function in the R language.

By calling this function, the user can evaluate the estimated intensity at any desired spatial locations.

Additionally f belongs to other classes which allow it to be printed and plotted easily.

The function f has arguments x,y,drop.

  • The arguments x,y of f specify the query locations. They can be numeric vectors of coordinates. Alternatively x can be a point pattern (or data acceptable to as.ppp) and y is omitted. The result of f(x,y) is a numeric vector giving the values of the intensity.

  • The argument drop of f specifies how to handle query locations which are outside the window of the original data. If drop=TRUE (the default), such locations are ignored. If drop=FALSE, a value of NA is returned for each such location.

Note that the smoothing parameters, such as the bandwidth sigma, are assigned when densityfun is executed. Smoothing parameters are fixed inside the function f and cannot be changed by arguments of f.

Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner r.turner@auckland.ac.nz and Ege Rubak rubak@math.aau.dk.

See Also

To interpolate values observed at the points, use Smoothfun.

Examples

f <- densityfun(swedishpines)
  f
  f(42, 60)
  X <- runifpoint(2, Window(swedishpines))
  f(X)
  plot(f)

spatstat.core

Core Functionality of the 'spatstat' Family

v2.1-2
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Kasper Klitgaard Berthelsen [ctb], Achmad Choiruddin [ctb], Jean-Francois Coeurjolly [ctb], Ottmar Cronie [ctb], Tilman Davies [ctb], Julian Gilbey [ctb], Yongtao Guan [ctb], Ute Hahn [ctb], Kassel Hingee [ctb], Abdollah Jalilian [ctb], Marie-Colette van Lieshout [ctb], Greg McSwiggan [ctb], Tuomas Rajala [ctb], Suman Rakshit [ctb], Dominic Schuhmacher [ctb], Rasmus Plenge Waagepetersen [ctb], Hangsheng Wang [ctb]
Initial release
2021-04-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.