"residuals"(object, type="raw", ..., check=TRUE, drop=FALSE, fittedvalues=NULL, new.coef=NULL, dropcoef=FALSE, quad=NULL)
"ppm"
)
for which residuals should be calculated.
"raw"
, "inverse"
, "pearson"
and "score"
.
A partial match is adequate.
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
.
quad.ppm
for
explanation.
coef(object)
.
See the section on Modified Residuals below.
quadscheme
.
See the section on Modified Residuals below.
"msr"
representing a signed measure or vector-valued measure
(see msr
). This object can be plotted.
new.coef
and quad
. If new.coef
is given, then the residuals will be computed
by taking the model parameters to be new.coef
.
This should be a numeric vector
of the same length as the vector of fitted model parameters
coef(object)
. If new.coef
is missing and quad
is given,
then the model parameters will
be determined by re-fitting the model using a new
quadrature scheme specified by quad
.
Residuals will be computed for the
original model object
using these new parameter values. The argument quad
should normally be
a list of arguments in name=value
format that will be
passed to quadscheme
(together with
the original data points) to determine the new quadrature scheme.
It may also be a quadrature scheme (object of class
"quad"
) to which the model should be fitted, or a
point pattern (object of class "ppp"
) specifying the
dummy points in a new quadrature scheme.plot.msr
to plot the residuals directly,
or 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
The result of residuals.ppm
is a measure
(object of class "msr"
).
Use plot.msr
to plot the residuals directly,
or diagnose.ppm
to produce diagnostic plots
based on these residuals.
Use integral.msr
to compute the total residual.
By default,
the window of the measure is the same as the original window
of the data. If drop=TRUE
then the window is the
domain of integration of the pseudolikelihood or composite likelihood.
This only matters when the model object
was fitted using
the border correction: in that case, if drop=TRUE
the
window of the residuals is the erosion of the original data window
by the border correction distance rbord
.
Baddeley, A., Moller, J. and Pakes, A.G. (2008) Properties of residuals for spatial point processes. Annals of the Institute of Statistical Mathematics 60, 627--649.
msr
,
diagnose.ppm
,
ppm.object
,
ppm
fit <- ppm(cells, ~x, Strauss(r=0.15))
# Pearson residuals
rp <- residuals(fit, type="pe")
rp
# simulated data
X <- rStrauss(100,0.7,0.05)
# fit Strauss model
fit <- ppm(X, ~1, Strauss(0.05))
res.fit <- residuals(fit)
# check that total residual is 0
integral.msr(residuals(fit, drop=TRUE))
# true model parameters
truecoef <- c(log(100), log(0.7))
res.true <- residuals(fit, new.coef=truecoef)
Run the code above in your browser using DataLab