# plot.ppm

##### plot a Fitted Point Process Model

Given a fitted point process model obtained by `ppm`

,
create spatial trend and conditional intensity surfaces of the model,
in a form suitable for plotting, and (optionally) plot these
surfaces.

##### Usage

```
## S3 method for class 'ppm':
plot(x, ngrid = c(40,40), superimpose = TRUE,
trend = TRUE, cif = TRUE, se = TRUE, pause = interactive(),
how=c("persp","image", "contour"), plot.it = TRUE,
locations = NULL, covariates=NULL, ...)
```

##### Arguments

- x
- A fitted point process model, typically obtained from
the model-fitting algorithm
`ppm`

. An object of class`"ppm"`

. - ngrid
- The dimensions for a grid on which to evaluate,
for plotting, the spatial trend and conditional intensity.
A vector of 1 or 2 integers. If it is of length 1,
`ngrid`

is replaced by`c(ngrid,ngrid)`

. - superimpose
- logical flag; if
`TRUE`

(and if`plot=TRUE`

) the original data point pattern will be superimposed on the plots. - trend
- logical flag; if
`TRUE`

, the spatial trend surface will be produced. - cif
- logical flag; if
`TRUE`

, the conditional intensity surface will be produced. - se
- logical flag; if
`TRUE`

, the estimated standard error of the spatial trend surface will be produced. - pause
- logical flag indicating whether to pause with a prompt
after each plot. Set
`pause=FALSE`

if plotting to a file. (This flag is ignored if`plot=FALSE`

). - how
- character string or character vector indicating the style or styles of
plots to be performed. Ignored if
`plot=FALSE`

. - plot.it
- logical scalar; should a plot be produced immediately?
- locations
- If present, this determines the locations of the pixels
at which predictions are computed. It must be a binary pixel image
(an object of class
`"owin"`

with type`"mask"`

). (Incompatible with`ngrid`

). - covariates
- Values of external covariates required by the fitted model.
Passed to
`predict.ppm`

. - ...
- extra arguments to the plotting functions
`persp`

,`image`

and`contour`

.

##### Details

This is the `plot`

method for the class `"ppm"`

(see `ppm.object`

for details of this class).
It invokes `predict.ppm`

to compute the spatial
trend and conditional intensity of the fitted point process model.
See `predict.ppm`

for more explanation about spatial trend
and conditional intensity.
The default action is to create a rectangular grid
of points in (the bounding box of) the observation window of
the data point pattern, and evaluate the spatial trend and
conditional intensity of the fitted spatial point process model
`x`

at these locations. If the argument `locations=`

is supplied, then the spatial trend
and conditional intensity are calculated at the grid of points
specified by this argument.

The argument `locations`

, if present, should be a
binary image mask (an object of class `"owin"`

and type `"mask"`

). This determines a rectangular grid
of locations, or a subset of such a grid, at which predictions
will be computed. Binary image masks
are conveniently created using `as.mask`

.

The argument `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 `x`

, `y`

)
then `covariates`

is required.

The argument `covariates`

has the same format and interpretation
as in `predict.ppm`

. It may be
either a data frame (the number of whose rows must match
the number of pixels in `locations`

multiplied by the number of
possible marks in the point pattern), or a list of images.
If argument `locations`

is not supplied, and `covariates`

**is** supplied, then
it **must** be a list of images.

If the fitted model was a marked (multitype) point process, then
predictions are made for each possible mark value in turn.
If the fitted model had no spatial trend, then the default is
to omit calculating this (flat) surface, unless `trend=TRUE`

is set explicitly.
If the fitted model was Poisson, so that there were no spatial interactions,
then the conditional intensity and spatial trend are identical, and the
default is to omit the conditional intensity, unless `cif=TRUE`

is set
explicitly.

If `plot.it=TRUE`

then `plot.plotppm()`

is called
upon to plot the class `plotppm`

object which is produced.
(That object is also returned, silently.)
Plots are produced successively using `persp`

,
`image`

and `contour`

(or only a
selection of these three, if `how`

is given). Extra
graphical parameters controlling the display may be passed
directly via the arguments `...`

or indirectly reset using
`spatstat.options`

.

##### Value

- An object of class
`plotppm`

. Such objects may be plotted by`plot.plotppm()`

.This is a list with components named

`trend`

and`cif`

, either of which may be missing. They will be missing if the corresponding component does not make sense for the model, or if the corresponding argument was set equal to`FALSE`

.Both

`trend`

and`cif`

are lists of images. If the model is an unmarked point process, then they are lists of length 1, so that`trend[[1]]`

is an image of the spatial trend and`cif[[1]]`

is an image of the conditional intensity.If the model is a marked point process, then

`trend[[i]]`

is an image of the spatial trend for the mark`m[i]`

, and`cif[[1]]`

is an image of the conditional intensity for the mark`m[i]`

, where`m`

is the vector of levels of the marks.

##### Warnings

See warnings in `predict.ppm`

.

##### See Also

`plot.plotppm`

,
`ppm`

,
`ppm.object`

,
`predict.ppm`

,
`print.ppm`

,
`persp`

,
`image`

,
`contour`

,
`plot`

,
`spatstat.options`

##### Examples

```
data(cells)
m <- ppm(cells, ~1, Strauss(0.05))
pm <- plot(m) # The object ``pm'' will be plotted as well as saved
# for future plotting.
```

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