ks.test.ppm {spatstat} | R Documentation |
Performs a Kolmogorov-Smirnov test of goodness-of-fit of a Poisson point process model. The test compares the observed and predicted distributions of the values of a spatial covariate.
ks.test.ppm(model, covariate, ...)
model |
A fitted point process model (object of class "ppm" ).
|
covariate |
The spatial covariate on which the test will be based.
An image (object of class "im" )
or a function.
|
... |
Arguments passed to ks.test
to control the test.
|
This function performs a goodness-of-fit test of a fitted point process model. 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
(object of class "ppm"
). It should be a Poisson point process.
The argument covariate
should be either a function(x,y)
or a pixel image (object of class "im"
containing the values
of a spatial function.
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 applied using
ks.test
.
This test was apparently first described (in the context of spatial data) by Berman (1986). See also Baddeley et al (2005).
An object of class "htest"
containing the results of the
test. See ks.test
for details.
Adrian Baddeley adrian@maths.uwa.edu.au http://www.maths.uwa.edu.au/~adrian/ and Rolf Turner rolf@math.unb.ca http://www.math.unb.ca/~rolf
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.
# nonuniform Poisson process X <- rpoispp(function(x,y) { 100 * exp(x) }, win=square(1)) # fit uniform Poisson process fit0 <- ppm(X, ~1) # fit correct nonuniform Poisson process fit1 <- ppm(X, ~x) # test covariate = x coordinate xcoord <- function(x,y) { x } # test wrong model ks.test.ppm(fit0, xcoord) # test right model ks.test.ppm(fit1, xcoord)