# clf.test

##### Cressie-Loosmore-Ford and Maximum Absolute Deviation Tests

Perform the Cressie (1991)/Loosmore and Ford (2006) test or the Maximum Absolute Deviation test for a spatial point pattern.

##### Usage

```
clf.test(X, ..., rinterval = NULL, use.theo=FALSE)
mad.test(X, ..., rinterval = NULL, use.theo=FALSE)
```

##### Arguments

- X
- Either a point pattern (object of class
`"ppp"`

,`"lpp"`

or other class), a fitted point process model (object of class`"ppm"`

,`"kppm"`

or other class) or an envelope object (class`"envelope"`

- ...
- Arguments passed to
`envelope`

. Useful arguments include`fun`

to determine the summary function,`nsim`

to specify the number of Monte Carlo simulations, and`verbose=`

- rinterval
- Interval of values of the summary function argument
`r`

over which the maximum absolute deviation, or the integral, will be computed for the test. A numeric vector of length 2. - use.theo
- Logical value determining whether to compare the summary function
for the data to its theoretical value for CSR (
`use.theo=TRUE`

) or to the sample mean of simulations from CSR (`use.theo=FALSE`

).

##### Details

These functions perform hypothesis tests for goodness-of-fit of a point pattern dataset to a point process model, based on Monte Carlo simulation from the model.

`clf.test`

performs the test advocated by Loosmore and Ford (2006)
which is also described in Cressie (1991, page 667, equation (8.5.42)).

`mad.test`

performs the

The type of test depends on the type of argument `X`

.

- If
`X`

is some kind of point pattern, then a test of Complete Spatial Randomness (CSR) will be performed. That is, the null hypothesis is that the point pattern is completely random. - If
`X`

is a fitted point process model, then a test of goodness-of-fit for the fitted model will be performed. The model object contains the data point pattern to which it was originally fitted. The null hypothesis is that the data point pattern is a realisation of the model. - If
`X`

is an envelope object generated by`envelope`

, then it should have been generated with`savefuns=TRUE`

or`savepatterns=TRUE`

so that it contains simulation results. These simulations will be treated as realisations from the null hypothesis.

`envelope`

to
generate or extract the simulated summary functions.
The number of simulations that will be generated or extracted,
is determined by the argument `nsim`

, and defaults to 99.
The summary function that will be computed is determined by the
argument `fun`

(or the first unnamed argument in the list
`...`

) and defaults to `Kest`

(except when
`X`

is an envelope object generated with `savefuns=TRUE`

,
when these functions will be taken). The choice of summary function `fun`

affects the power of the
test. It is normally recommended to apply a variance-stabilising
transformation (Ripley, 1981). If you are using the $K$ function,
the normal practice is to replace this by the $L$ function
(Besag, 1977) computed by `Lest`

. If you are using
the $F$ or $G$ functions, the recommended practice is to apply
Fisher's variance-stabilising transformation
$\sin^{-1}\sqrt x$ using the argument
`transform`

. See the Examples.

##### Value

- An object of class
`"htest"`

. Printing this object gives a report on the result of the test. The $p$-value is contained in the component`p.value`

.

##### References

Besag, J. (1977)
Discussion of Dr Ripley's paper.
*Journal of the Royal Statistical Society, Series B*,
**39**, 193--195.
Cressie, N.A.C. (1991)
*Statistics for spatial data*.
John Wiley and Sons, 1991.

Loosmore, N.B. and Ford, E.D. (2006)
Statistical inference using the *G* or *K* point
pattern spatial statistics. *Ecology* **87**, 1925--1931.

Ripley, B.D. (1977)
Modelling spatial patterns (with discussion).
*Journal of the Royal Statistical Society, Series B*,
**39**, 172 -- 212.

Ripley, B.D. (1981)
*Spatial statistics*.
John Wiley and Sons.

##### See Also

##### Examples

```
clf.test(cells, Lest)
m <- mad.test(cells, Lest, verbose=FALSE, rinterval=c(0, 0.1))
m
# extract the p-value
m$p.value
# variance stabilised G function
clf.test(cells, Gest, transform=expression(asin(sqrt(.))), verbose=FALSE)
```

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