mppm(formula, data, interaction=Poisson(), ..., iformula=NULL, random=NULL, use.gam = FALSE, reltol.pql=1e-3, gcontrol=list())
data
.
"hyperframe"
,
see hyperframe
) containing the
point pattern responses and the explanatory variables.
"interact"
describing the point process interaction
structure, or a hyperframe (with the same number of
rows as data
) whose entries are objects of class
"interact"
.
ppm
controlling
the fitting procedure.
interaction
, or the name of a column
in the hyperframe data
that is a vector or factor.
data
and interaction
.
The formula must be recognisable to lme
.
reltol.pql
.
glm.control
or gam.control
or lmeControl
depending on the kind of model being fitted.
If the model has random effects, the arguments are passed to
lmeControl
. Otherwise,
if use.gam=TRUE
the arguments are passed to
gam.control
, and if
use.gam=FALSE
(the default) they are passed to
glm.control
.
random
is a formula,
with no left-hand side, that specifies the structure of the
random effects. The formula should be recognisable to
lme
(see the description of the argument random
for lme
). The names in the formula random
may be any of the covariates
supplied by data
.
Additionally the formula may involve the name
id
, which is a factor representing the
serial number ($1$ to $n$) of the point pattern in the
list X
.ppm
to deal with data such as
The syntax of this function is similar to that of
standard R model-fitting functions like lm
and
glm
. The first argument formula
is an R formula
describing the systematic part of the model. The second argument
data
contains the responses and the explanatory variables.
Other arguments determine the stochastic structure of the model.
Schematically,
the data are regarded as the results of a designed experiment
involving $n$ experimental units. Each unit has a
response, and optionally some explanatory variables
(covariates) describing the experimental conditions for that unit.
In this context,
the response from each unit is a point pattern.
The value of a particular covariate for each unit can be
either a single value (numerical, logical or factor),
or a spatial covariate.
A spatial covariate is a quantity that depends on spatial location,
for example, the soil acidity or altitude at each location.
For the purposes of mppm
, a spatial covariate must be stored
as a pixel image (object of class "im"
) which gives the values
of the covariate at a fine grid of locations.
The argument data
is a hyperframe (a generalisation of
a data frame, see hyperframe
). This is like a data frame
except that the entries can be objects of any class.
The hyperframe has one row for each experimental unit,
and one column for each variable (response or explanatory variable).
The formula
should be an R formula.
The left hand side of formula
determines the response
variable. This should be a single name, which
should correspond to a column in data
.
The right hand side of formula
determines the
spatial trend of the model. It specifies the linear predictor,
and effectively represents the logarithm
of the spatial trend.
Variables in the formula must be the names of columns of
data
, or one of the reserved names
The column of responses in data
must consist of point patterns (objects of class "ppp"
).
The individual point pattern responses
can be defined in different spatial windows.
If some of the point patterns are marked, then they must all be
marked, and must have the same type of marks.
The scope of models that can be fitted to each pattern is the same as the
scope of ppm
, that is, Gibbs point processes with
interaction terms that belong to a specified list, including
for example the Poisson process, Strauss process, Geyer's saturation
model, and piecewise constant pairwise interaction models.
Additionally, it is possible to include random effects
as explained in the section on Random Effects below.
The stochastic part of the model is determined by
the arguments interaction
and (optionally) iformula
.
interaction
is
an object of class "interact"
,
determining the interpoint interaction structure of the point
process model, for all experimental units.
interaction
may be a hyperframe,
whose entries are objects of class "interact"
.
It should have the same number of rows as data
.
interaction
consists of only one column,
then the entry in row i
is taken to be the
interpoint interaction for the i
th experimental unit
(corresponding to the i
th row of data
).
interaction
has more than one column,
then the argument iformula
is also required.
Each row of interaction
determines
several interpoint interaction structures that might be applied
to the corresponding row of data
.
The choice of interaction is determined by iformula
;
this should be an R formula,
without a left hand side.
For example if interaction
has two columns called
A
and B
then iformula = ~B
indicates that the
interpoint interactions are taken from the second column.
Variables in iformula
typically refer to column names of interaction
.
They can also be names of columns in
data
, but only for columns of numeric, logical or factor
values. For example iformula = ~B * group
(where group
is a column of data
that contains a factor) causes the
model with interpoint interaction B
to be fitted
with different interaction parameters for each level of group
.
Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. London: Chapman and Hall/CRC Press.
Bell, M. and Grunwald, G. (2004) Mixed models for the analysis of replicated spatial point patterns. Biostatistics 5, 633--648.
ppm
,
print.mppm
,
summary.mppm
,
coef.mppm
,
# Waterstriders data
H <- hyperframe(Y = waterstriders)
mppm(Y ~ 1, data=H)
mppm(Y ~ 1, data=H, Strauss(7))
mppm(Y ~ id, data=H)
mppm(Y ~ x, data=H)
# Synthetic data from known model
n <- 10
H <- hyperframe(V=1:n,
U=runif(n, min=-1, max=1),
M=factor(letters[1 + (1:n) %% 3]))
H$Z <- setcov(square(1))
H$U <- with(H, as.im(U, as.rectangle(Z)))
H$Y <- with(H, rpoispp(eval.im(exp(2+3*Z))))
fit <- mppm(Y ~Z + U + V, data=H)
Run the code above in your browser using DataLab