# anova.ppm

##### ANOVA for Fitted Point Process Models

Performs analysis of deviance for one or more fitted point process models.

##### Usage

```
# S3 method for ppm
anova(object, …, test=NULL,
adjust=TRUE, warn=TRUE, fine=FALSE)
```

##### Arguments

- object
A fitted point process model (object of class

`"ppm"`

).- …
Optional. Additional objects of class

`"ppm"`

.- test
Character string, partially matching one of

`"Chisq"`

,`"LRT"`

,`"Rao"`

,`"score"`

,`"F"`

or`"Cp"`

, or`NULL`

indicating that no test should be performed.- adjust
Logical value indicating whether to correct the pseudolikelihood ratio when some of the models are not Poisson processes.

- warn
Logical value indicating whether to issue warnings if problems arise.

- fine
Logical value, passed to

`vcov.ppm`

, indicating whether to use a quick estimate (`fine=FALSE`

, the default) or a slower, more accurate estimate (`fine=TRUE`

) of variance terms. Relevant only when some of the models are not Poisson and`adjust=TRUE`

.

##### Details

This is a method for `anova`

for
fitted point process models (objects of class `"ppm"`

,
usually generated by the model-fitting function `ppm`

).

If the fitted models are all Poisson point processes,
then by default, this function performs an Analysis of Deviance of
the fitted models. The output shows the deviance differences
(i.e. 2 times log likelihood ratio),
the difference in degrees of freedom, and (if `test="Chi"`

or `test="LRT"`

)
the two-sided p-values for the chi-squared tests. Their interpretation
is very similar to that in `anova.glm`

.
If `test="Rao"`

or `test="score"`

,
the *score test* (Rao, 1948) is performed instead.

If some of the fitted models are *not* Poisson point processes,
the `deviance' differences in this table are
'pseudo-deviances' equal to 2 times the differences
in the maximised values of the log pseudolikelihood (see
`ppm`

). It is not valid to compare these
values to the chi-squared distribution. In this case,
if `adjust=TRUE`

(the default), the
pseudo-deviances will be adjusted using the method of Pace et al
(2011) and Baddeley et al (2015) so that the chi-squared test is valid.
It is strongly advisable to perform this adjustment.

##### Value

An object of class `"anova"`

, or `NULL`

.

##### Errors and warnings

- models not nested:
There may be an error message that the models are not “nested”. For an Analysis of Deviance the models must be nested, i.e. one model must be a special case of the other. For example the point process model with formula

`~x`

is a special case of the model with formula`~x+y`

, so these models are nested. However the two point process models with formulae`~x`

and`~y`

are not nested.If you get this error message and you believe that the models should be nested, the problem may be the inability of R to recognise that the two formulae are nested. Try modifying the formulae to make their relationship more obvious.

- different sizes of dataset:
There may be an error message from

`anova.glmlist`

that “models were not all fitted to the same size of dataset”. This implies that the models were fitted using different quadrature schemes (see`quadscheme`

) and/or with different edge corrections or different values of the border edge correction distance`rbord`

.To ensure that models are comparable, check the following:

the models must all have been fitted to the same point pattern dataset, in the same window.

all models must have been fitted by the same fitting method as specified by the argument

`method`

in`ppm`

.If some of the models depend on covariates, then they should all have been fitted using the same list of covariates, and using

`allcovar=TRUE`

to ensure that the same quadrature scheme is used.all models must have been fitted using the same edge correction as specified by the arguments

`correction`

and`rbord`

. If you did not specify the value of`rbord`

, then it may have taken a different value for different models. The default value of`rbord`

is equal to zero for a Poisson model, and otherwise equals the reach (interaction distance) of the interaction term (see`reach`

). To ensure that the models are comparable, set`rbord`

to equal the maximum reach of the interactions that you are fitting.

##### Error messages

An error message that reports
*system is computationally singular* indicates that the
determinant of the Fisher information matrix of one of the models
was either too large or too small for reliable numerical calculation.
See `vcov.ppm`

for suggestions on how to handle this.

##### References

Baddeley, A., Turner, R. and Rubak, E. (2015)
Adjusted composite likelihood ratio test for Gibbs point processes.
*Journal of Statistical Computation and Simulation*
**86** (5) 922--941.
DOI: 10.1080/00949655.2015.1044530.

Pace, L., Salvan, A. and Sartori, N. (2011)
Adjusting composite likelihood ratio statistics.
*Statistica Sinica* **21**, 129--148.

Rao, C.R. (1948)
Large sample tests of statistical hypotheses concerning
several parameters with applications to problems of
estimation. *Proceedings of the Cambridge Philosophical Society*
**44**, 50--57.

##### See Also

##### Examples

```
# NOT RUN {
mod0 <- ppm(swedishpines ~1)
modx <- ppm(swedishpines ~x)
# Likelihood ratio test
anova(mod0, modx, test="Chi")
# Score test
anova(mod0, modx, test="Rao")
# Single argument
modxy <- ppm(swedishpines ~x + y)
anova(modxy, test="Chi")
# Adjusted composite likelihood ratio test
modP <- ppm(swedishpines ~1, rbord=9)
modS <- ppm(swedishpines ~1, Strauss(9))
anova(modP, modS, test="Chi")
# }
```

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