Description Usage Arguments Details Value Warning Author(s) References See Also Examples
Performs a test of goodnessoffit of a point process model on a linear network. The observed and predicted distributions of the values of a spatial covariate are compared using either the KolmogorovSmirnov test, Cramervon Mises test or AndersonDarling test. For nonPoisson models, a Monte Carlo test is used.
1 2 3 4 5 6 7 
X 
A point pattern on a linear network (object of class 
model 
A fitted point process model on a linear network
(object of class 
covariate 
The spatial covariate on which the test will be based.
A function, a pixel image (object of class 
test 
Character string identifying the test to be performed:

... 
Arguments passed to 
interpolate 
Logical flag indicating whether to interpolate pixel images.
If 
jitter 
Logical flag. If 
nsim 
Number of simulated realisations from the 
verbose 
Logical value indicating whether to print progress reports when performing a Monte Carlo test. 
These functions perform a goodnessoffit test of a Poisson point process model fitted to point pattern data on a linear network. 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 KolmogorovSmirnov test, the Cramervon Mises test or the AndersonDarling test. For Gibbs models, a Monte Carlo test is performed using these test statistics.
The function cdf.test
is generic, with methods for
point patterns ("ppp"
or "lpp"
),
point process models ("ppm"
or "lppm"
)
and spatial logistic regression models ("slrm"
).
See the help file for cdf.test
for information on the generic function and the methods
for data in twodimensional space, classes "ppp"
, "ppm"
and "slrm"
.
This help file describes the methods for data on a linear network,
classes "lpp"
and "lppm"
.
If X
is a point pattern on a linear network (object of class
"lpp"
), then cdf.test(X, ...)
performs a goodnessoffit test of the
uniform Poisson point process (Complete Spatial Randomness, CSR)
for this dataset.
For a multitype point pattern, the uniform intensity
is assumed to depend on the type of point (sometimes called
Complete Spatial Randomness and Independence, CSRI).
If model
is a fitted point process model on a network
(object of class "lppm"
)
then cdf.test(model, ...)
performs
a test of goodnessoffit for this fitted model.
The test is performed by comparing the observed distribution of the values of a spatial covariate at the data points, and the predicted distribution of the same covariate under the model, using a classical goodnessoffit test. Thus, you must nominate a spatial covariate for this test.
If X
is a point pattern that does not have marks,
the argument covariate
should be either a function(x,y)
or a pixel image (object of class "im"
or "linim"
)
containing the values
of a spatial function, or one of the characters "x"
or
"y"
indicating the Cartesian coordinates.
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
.
If X
is a multitype point pattern, the argument covariate
can be either a function(x,y,marks)
,
or a pixel image, or a list of pixel images corresponding to
each possible mark value, or one of the characters "x"
or
"y"
indicating the Cartesian coordinates.
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
A goodnessoffit test of the uniform distribution is applied
to these numbers using stats::ks.test
,
goftest::cvm.test
or
goftest::ad.test
.
This test was apparently first described (in the context of twodimensional spatial data, and using KolmogorovSmirnov) by Berman (1986). See also Baddeley et al (2005).
If model
is not a Poisson process, then
a Monte Carlo test is performed, by generating nsim
point patterns which are simulated realisations of the model
,
refitting the model to each simulated point pattern,
and calculating the test statistic for each fitted model.
The Monte Carlo p value is determined by comparing
the simulated values of the test statistic
with the value for the original data.
The return value is an object of class "htest"
containing the
results of the hypothesis test. The print method for this class
gives an informative summary of the test outcome.
The return value also belongs to the class "cdftest"
for which there is a plot method plot.cdftest
.
The plot method displays the empirical cumulative distribution
function of the covariate at the data points, and the predicted
cumulative distribution function of the covariate under the model,
plotted against the value of the covariate.
The argument jitter
controls whether covariate values are
randomly perturbed, in order to avoid ties.
If the original data contains any ties in the covariate (i.e. points
with equal values of the covariate), and if jitter=FALSE
, then
the KolmogorovSmirnov test implemented in ks.test
will issue a warning that it cannot calculate the exact pvalue.
To avoid this, if jitter=TRUE
each value of the covariate will
be perturbed by adding a small random value. The perturbations are
normally distributed with standard deviation equal to one hundredth of
the range of values of the covariate. This prevents ties,
and the pvalue is still correct. There is
a very slight loss of power.
An object of class "htest"
containing the results of the
test. See ks.test
for details. The return value can be
printed to give an informative summary of the test.
The value also belongs to the class "cdftest"
for which there is
a plot method.
The outcome of the test involves a small amount of random variability,
because (by default) the coordinates are randomly perturbed to
avoid tied values. Hence, if cdf.test
is executed twice, the
pvalues will not be exactly the same. To avoid this behaviour,
set jitter=FALSE
.
and \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.
plot.cdftest
,
quadrat.test
,
berman.test
,
ks.test
,
goftest::cvm.test
,
goftest::ad.test
,
lppm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  op < options(useFancyQuotes=FALSE)
# test of CSR using x coordinate
cdf.test(spiders, "x")
# fit inhomogeneous Poisson model and test
model < lppm(spiders ~x)
cdf.test(model, "y")
# test of CSR using a function of x and y
fun < function(x,y){2* x + y}
cdf.test(spiders, fun)
# test of CSR using an image covariate
fim < as.linim(fun, domain(spiders))
cdf.test(spiders, fim)
options(op)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.