Prediction from a Fitted Point Process Model
Given a fitted point process model obtained by
evaluate the spatial trend or the conditional intensity of the model
at new locations.
1 2 3 4 5 6 7 8 9
A fitted point process model, typically obtained from
the model-fitting algorithm
Optional. A window (object of class
Optional. Dimensions of a rectangular grid of locations
Optional. Data giving the exact
x,y coordinates (and marks, if required)
of locations at which predictions should be computed.
Either a point pattern, or a data frame with columns named
Values of external covariates required by the model. Either a data frame or a list of images. See Details.
Indicates which property of the fitted model should be predicted.
Logical value indicating whether to calculate standard errors as well.
String (partially matched) indicating whether to produce
Coverage probability for the confidence or prediction interval.
Optional. A point pattern (object of class
Name of the edge correction to be used
in calculating the conditional intensity.
Numeric vector of parameter values to replace the
fitted model parameters
Logical value indicating whether to check the internal format
Logical value indicating whether to repair the internal format
This function computes properties of a fitted spatial point process
model (object of class
"ppm"). For a Poisson point process
it can compute the fitted intensity function, or the expected number of
points in a region. For a Gibbs point process it can compute the
spatial trend (first order potential), conditional intensity,
and approximate intensity of the process.
Point estimates, standard errors,
confidence intervals and prediction intervals are available.
Given a point pattern dataset, we may fit
a point process model to the data using the
returns an object of class
the fitted point process model (see
The parameter estimates in this fitted model can be read off
simply by printing the
The spatial trend, conditional intensity and intensity of the
fitted model are evaluated using this function
The default action is to create a rectangular grid of points in the observation window of the data point pattern, and evaluate the spatial trend at these locations.
type specifies the values that are desired:
the “spatial trend” of the fitted model is evaluated at each required spatial location u. See below.
the conditional intensity lambda(u,X) of the fitted model is evaluated at each required spatial location u, with respect to the data point pattern X.
the intensity lambda(u) of the fitted model is evaluated at each required spatial location u.
the expected total number of points (or the expected number of points falling in
window) is evaluated. If
windowis a tessellation, the expected number of points in each tile of the tessellation is evaluated.
The spatial trend, conditional intensity, and intensity are all equivalent if the fitted model is a Poisson point process. However, if the model is not a Poisson process, then they are all different. The “spatial trend” is the (exponentiated) first order potential, and not the intensity of the process. [For example if we fit the stationary Strauss process with parameters beta and gamma, then the spatial trend is constant and equal to beta, while the intensity is a smaller value.]
The default is to compute an estimate of the desired quantity.
the estimate is replaced by a confidence interval or prediction interval.
se=TRUE, then a standard error is also calculated,
and is returned together with the (point or interval) estimate.
The spatial locations where predictions are required,
are determined by the (incompatible)
If the argument
ngridis present, then predictions are performed at a rectangular grid of locations in the window
window. The result of prediction will be a pixel image or images.
locationsis present, then predictions will be performed at the spatial locations given by this dataset. These may be an arbitrary list of spatial locations, or they may be a rectangular grid. The result of prediction will be either a numeric vector or a pixel image or images.
locationsis given, then
ngridis assumed. The value of
spatstat.options("npixel"), which is initialised to 128 when spatstat is loaded.
locations may be a point pattern,
a data frame or a list specifying arbitrary locations;
or it may be a binary image mask (an object of class
"mask") or a pixel image (object of class
"im") specifying (a subset of) a rectangular
grid of locations.
locationsis a point pattern (object of class
"ppp"), then prediction will be performed at the points of the point pattern. The result of prediction will be a vector of predicted values, one value for each point. If the model is a marked point process, then
locationsshould be a marked point pattern, with marks of the same kind as the model; prediction will be performed at these marked points. The result of prediction will be a vector of predicted values, one value for each (marked) point.
locationsis a data frame or list, then it must contain vectors
locations$yspecifying the x,y coordinates of the prediction locations. Additionally, if the model is a marked point process, then
locationsmust also contain a factor
locations$marksspecifying the marks of the prediction locations. These vectors must have equal length. The result of prediction will be a vector of predicted values, of the same length.
locationsis a binary image mask, then prediction will be performed at each pixel in this binary image where the pixel value is
TRUE(in other words, at each pixel that is inside the window). If the fitted model is an unmarked point process, then the result of prediction will be an image. If the fitted model is a marked point process, then prediction will be performed for each possible value of the mark at each such location, and the result of prediction will be a list of images, one for each mark value.
locationsis a pixel image (object of class
"im"), then prediction will be performed at each pixel in this image where the pixel value is defined (i.e.\ where the pixel value is not
covariates gives the values of any spatial covariates
at the prediction locations.
If the trend formula in the fitted model
involves spatial covariates (other than
the Cartesian coordinates
covariates is required.
The format and use of
covariates are analogous to those of the
argument of the same name in
It is either a data frame or a list of images.
covariatesis a list of images, then the names of the entries should correspond to the names of covariates in the model formula
trend. Each entry in the list must be an image object (of class
im.object). The software will look up the pixel values of each image at the quadrature points.
covariatesis a data frame, then the
ith row of
covariatesis assumed to contain covariate data for the
ith location. When
locationsis a data frame, this just means that each row of
covariatescontains the covariate data for the location specified in the corresponding row of
locationsis a binary image mask, the row
covariates[i,]must correspond to the location
x = as.vector(raster.x(locations))and
y = as.vector(raster.y(locations)).
Note that if you only want to use prediction in order to
generate a plot of the predicted values,
it may be easier to use
plot.ppm which calls
this function and plots the results.
total is given:
a numeric vector or matrix.
locations is given and is a data frame:
a vector of predicted values for the spatial locations
(and marks, if required) given in
ngrid is given, or if
locations is given
and is a binary image mask or a pixel image:
object is an unmarked point process,
the result is a pixel image object (of class
im.object) containing the predictions.
object is a multitype point process,
the result is a list of pixel images, containing the predictions
for each type at the same grid of locations.
The “predicted values” are either values of the spatial trend
type="trend"), values of the conditional intensity
values of the intensity (if
or numbers of points (if
se=TRUE, then the result is a list with two entries,
the first being the predicted values in the format described above,
and the second being the standard errors in the same format.
The current implementation invokes
so that prediction is wrong if the trend formula in
object involves terms in
This is a weakness of
Error messages may be very opaque,
as they tend to come from deep in the workings of
If you are passing the
and the function crashes,
it is advisable to start by checking that all the conditions
listed above are satisfied.
Baddeley, A. and Turner, R. Practical maximum pseudolikelihood for spatial point patterns. Australian and New Zealand Journal of Statistics 42 (2000) 283–322.
Berman, M. and Turner, T.R. Approximating point process likelihoods with GLIM. Applied Statistics 41 (1992) 31–38.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
m <- ppm(cells ~ polynom(x,y,2), Strauss(0.05)) trend <- predict(m, type="trend") ## Not run: image(trend) points(cells) ## End(Not run) cif <- predict(m, type="cif") ## Not run: persp(cif) ## End(Not run) data(japanesepines) mj <- ppm(japanesepines ~ harmonic(x,y,2)) se <- predict(mj, se=TRUE) # prediction interval for total number of points predict(mj, type="count", interval="p") # prediction at arbitrary locations predict(mj, locations=data.frame(x=0.3, y=0.4)) X <- runifpoint(5, Window(japanesepines)) predict(mj, locations=X, se=TRUE) # multitype rr <- matrix(0.06, 2, 2) ma <- ppm(amacrine ~ marks, MultiStrauss(rr)) Z <- predict(ma) Z <- predict(ma, type="cif") predict(ma, locations=data.frame(x=0.8, y=0.5,marks="on"), type="cif")
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.