residuals.ppm {spatstat} | R Documentation |
Given a point process model fitted to a point pattern, compute residuals.
## S3 method for class 'ppm': residuals(object, type="raw", ..., check=TRUE, fittedvalues=fitted.ppm(object, check=check))
object |
The fitted point process model (an object of class "ppm" )
for which residuals should be calculated.
|
type |
String indicating the type of residuals to be calculated.
Current options are
"raw" , "inverse" and "pearson" .
A partial match is adequate.
|
... |
Ignored. |
check |
Logical value indicating whether to check the internal format
of object . If there is any possibility that this object
has been restored from a dump file, or has otherwise lost track of
the environment where it was originally computed, set
check=TRUE .
|
fittedvalues |
Vector of fitted values for the conditional intensity at the quadrature points, from which the residuals will be computed. For expert use only. |
This function computes several kinds of residuals for the fit of
a point process model to a spatial point pattern dataset
(Baddeley et al, 2005).
Use diagnose.ppm
to produce diagnostic plots
based on these residuals.
The argument object
must be a fitted point process model
(object of class "ppm"
). Such objects are produced by the maximum
pseudolikelihood fitting algorithm ppm
).
This fitted model object contains complete
information about the original data pattern.
Residuals are attached both to the data points and to some other points in the window of observation (namely, to the dummy points of the quadrature scheme used to fit the model). If the fitted model is correct, then the sum of the residuals over all (data and dummy) points in a spatial region B has mean zero. For further explanation, see Baddeley et al (2005).
The type of residual
is chosen by the argument type
. Current options are
"raw"
:r[j] = z[j] - w[j] lambda[j]
at the quadrature points u[j], where z[j] is the indicator equal to 1 if u[j] is a data point and 0 if u[j] is a dummy point; w[j] is the quadrature weight attached to u[j]; and
lambda[j] = lambda(u[j],x)
is the conditional intensity of the fitted model at u[j]. These are the spatial analogue of the martingale residuals of a one-dimensional counting process.
"inverse"
:rI[j] = r[j]/lambda[j] = z[j]/lambda[j] - w[j]
obtained by dividing the raw residuals by
the fitted conditional intensity. These are
a counterpart of the exponential energy marks (see eem
).
"pearson"
:rP[j] = r[j]/sqrt(lambda[j]) = z[j]/sqrt(lambda[j]) - w[j] sqrt(lambda[j])
obtained by dividing the raw residuals by the square root of the fitted conditional intensity. The Pearson residuals are standardised, in the sense that if the model (true and fitted) is Poisson, then the sum of the Pearson residuals in a spatial region B has variance equal to the area of B.
Use diagnose.ppm
to produce diagnostic plots
based on these residuals.
A vector containing the (discretised) residuals.
Entries in this vector correspond to the quadrature points (data or
dummy points) used to fit the model. The quadrature points can be
extracted from object
by union.quad(quad.ppm(object))
.
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.
data(cells) fit <- ppm(cells, ~x, Strauss(r=0.15), rbord=0.15) rp <- residuals.ppm(fit, type="pe") sum(rp) # should be close to 0 # extract quadrature points to which the residuals correspond quadpoints <- union.quad(quad.ppm(fit)) # plot residuals as marks attached to the quadrature points quadmarked <- setmarks(quadpoints, rp) plot(quadmarked)