# default.expand

##### Default Expansion Rule for Simulation of Model

Defines the default expansion window or expansion rule for simulation of a fitted point process model.

##### Usage

`default.expand(object, m=2, epsilon=1e-6, w=Window(object))`

##### Arguments

- object
A point process model (object of class

`"ppm"`

or`"rmhmodel"`

).- m
A single numeric value. The window will be expanded by a distance

`m * reach(object)`

along each side.- epsilon
Threshold argument passed to

`reach`

to determine`reach(object)`

.- w
Optional. The un-expanded window in which the model is defined. The resulting simulated point patterns will lie in this window.

##### Details

This function computes a default value for the
expansion rule (the argument `expand`

in `rmhcontrol`

)
given a fitted point process model `object`

.
This default is used by `envelope`

,
`qqplot.ppm`

, `simulate.ppm`

and other functions.

Suppose we wish to generate simulated realisations
of a fitted point process model inside a window `w`

.
It is advisable to first simulate
the pattern on a larger window, and then clip it to the original
window `w`

. This avoids edge effects in the simulation.
It is called *expansion* of the simulation window.

Accordingly, for the Metropolis-Hastings simulation algorithm
`rmh`

, the algorithm control parameters specified by
`rmhcontrol`

include an argument `expand`

that
determines the expansion of the simulation window.

The function `default.expand`

determines the default expansion
rule for a fitted point process model `object`

.

If the model is Poisson, then no expansion is necessary.
No expansion is performed by default,
and `default.expand`

returns a rule representing no expansion.
The simulation window is the original window `w = Window(object)`

.

If the model depends on external covariates (i.e.\ covariates other than
the Cartesian covariates `x`

and `y`

and the `marks`

)
then no expansion is feasible, in general, because the spatial domain
of the covariates is not guaranteed to be large enough.
`default.expand`

returns a rule representing no expansion.
The simulation window is the original window `w = Window(object)`

.

If the model depends on the Cartesian covariates `x`

and `y`

,
it would be feasible to expand the simulation window, and this was the
default for spatstat version 1.24-1 and earlier.
However this sometimes produces artefacts (such as an empty point pattern)
or memory overflow, because the fitted trend, extrapolated outside the
original window of the data, may become very large.
In spatstat version 1.24-2 and later, the
default rule is *not* to expand if the model depends
on `x`

or `y`

.
Again `default.expand`

returns a rule representing no expansion.

Otherwise, expansion will occur.
The original window `w = Window(object)`

is expanded by
a distance `m * rr`

, where
`rr`

is the interaction range of the model, computed by
`reach`

. If `w`

is a rectangle then
each edge of `w`

is displaced outward by distance `m * rr`

.
If `w`

is not a rectangle then `w`

is dilated by
distance `m * rr`

using `dilation`

.

##### Value

A window expansion rule (object of class `"rmhexpand"`

).

##### See Also

##### Examples

```
# NOT RUN {
data(cells)
fit <- ppm(cells, ~1, Strauss(0.07))
default.expand(fit)
mod <- rmhmodel(cif="strauss", par=list(beta=100, gamma=0.5, r=0.07))
default.expand(fit)
# }
```

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