# kstest.mppm

0th

Percentile

##### Kolmogorov-Smirnov Test for Multiple Point Process Model

Performs a Kolmogorov-Smirnov test of goodness-of-fit of a Poisson point process model fitted to multiple spatial point patterns. The test compares the observed and predicted distributions of the values of a spatial covariate.

Keywords
htest, spatial
##### Usage
## S3 method for class 'mppm':
kstest(model, covariate, ...,
verbose=TRUE, interpolate=FALSE, fast=TRUE, jitter=TRUE)
##### Arguments
model
An object of class "mppm" representing a point process model fitted to multiple spatial point patterns.
covariate
The spatial covariate on which the test will be based. A function, a pixel image, a list of functions, a list of pixel images, a hyperframe, or a character string containing the name of one of the covariates in model.
...
Arguments passed to ks.test to control the test.
verbose
Logical flag indicating whether to print progress reports.
interpolate
Logical flag indicating whether to interpolate between pixel values when code{covariate} is a pixel image. See Details.
fast
Logical flag. If TRUE, values of the covariate are only sampled at the original quadrature points used to fit the model. If FALSE, values of the covariate are sampled at all pixels, which can be slower by three orders
jitter
Logical flag. If TRUE, observed values of the covariate are perturbed by adding small random values, to avoid tied observations.
##### Details

This function is a method for the generic function kstest for the class mppm.

This function performs a goodness-of-fit test of a point process model that has been fitted to multiple point patterns. The observed distribution of the values of a spatial covariate at the data points, and the predicted distribution of the same values under the model, are compared using the Kolmogorov-Smirnov test. The argument model should be a fitted point process model fitted to multiple point patterns (object of class "mppm"). It should be a Poisson point process. The argument covariate contains the values of a spatial function. It can be

• afunction(x,y)
• a pixel image (object of class"im"
• a list offunction(x,y), one for each point pattern
• a list of pixel images, one for each point pattern
• a hyperframe (seehyperframe) of which the first column will be taken as containing the covariate
• a character string giving the name of one of the covariates inmodel.
If covariate is an image, it should have numeric values, and its domain should cover the observation window of the model. If covariate is a function, it should expect two arguments x and y which are vectors of coordinates, and it should return a numeric vector of the same length as x and y.

First the original data point pattern is extracted from model. The values of the covariate at these data points are collected.

The predicted distribution of the values of the covariate under the fitted model is computed as follows. The values of the covariate at all locations in the observation window are evaluated, weighted according to the point process intensity of the fitted model, and compiled into a cumulative distribution function $F$ using ewcdf.

The probability integral transformation is then applied: the values of the covariate at the original data points are transformed by the predicted cumulative distribution function $F$ into numbers between 0 and 1. If the model is correct, these numbers are i.i.d. uniform random numbers. The Kolmogorov-Smirnov test of uniformity is then applied using the Rcore function ks.test.

This test was apparently first described (in the context of spatial data) by Berman (1986). See also Baddeley et al (2005).

The argument interpolate determines how pixel values will be handled when code{covariate} is a pixel image. The value of the covariate at a data point is obtained by looking up the value of the nearest pixel if interpolate=FALSE, or by linearly interpolating between the values of the four nearest pixels if interpolate=TRUE. Linear interpolation is slower, but is sometimes necessary to avoid tied values of the covariate arising when the pixel grid is coarse.

##### Value

• An object of class "htest" containing the results of the test. See ks.test for details.

##### References

Baddeley, A., Turner, R., Moller, J. and Hazelton, M. (2005) Residual analysis for spatial point processes. Journal of the Royal Statistical Society, Series B 67, 617--666.

Berman, M. (1986) Testing for spatial association between a point process and another stochastic process. Applied Statistics 35, 54--62.

ks.test, quadrat.test, mppm

• kstest.mppm
##### Examples
# three i.i.d. realisations of nonuniform Poisson process
lambda <- as.im(function(x,y) { 300 * exp(x) }, square(1))
dat <- hyperframe(X=list(rpoispp(lambda), rpoispp(lambda), rpoispp(lambda)))

# fit uniform Poisson process
fit0 <- mppm(X~1, dat)
# fit correct nonuniform Poisson process
fit1 <- mppm(X~x, dat)

# test covariate = x coordinate
xcoord <- function(x,y) { x }

# test wrong model
kstest.mppm(fit0, xcoord)
# test right model
kstest.mppm(fit1, xcoord)
Documentation reproduced from package spatstat, version 1.37-0, License: GPL (>= 2)

### Community examples

Looks like there are no examples yet.