| residuals.lppm | R Documentation |
Given a point process model fitted to a point pattern on a linear network, compute residuals of the fitted model.
## S3 method for class 'lppm'
residuals(object, type="raw", ...)
object |
The fitted point process model (an object of class |
type |
String indicating the type of residuals to be calculated.
Current options are
|
... |
Other arguments are currently ignored. |
This function computes several kinds of residuals for the fit of
a point process model to a spatial point pattern on a linear network.
It is an extension of the method of Baddeley et al (2005)
to point process models on a network.
Use plot.msr to plot the residuals directly.
The argument object must be a fitted point process model
on a network (object of class "lppm").
Such objects are produced by the model-fitting algorithm lppm.
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":the raw residuals
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 = \hat\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":the ‘inverse-lambda’ residuals (Baddeley et al, 2005)
r^{(I)}_j = \frac{r_j}{\lambda_j}
= \frac{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":the Pearson residuals (Baddeley et al, 2005)
r^{(P)}_j = \frac{r_j}{\sqrt{\lambda_j}}
= \frac{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.
"score":the score residuals (Baddeley et al, 2005)
r_j = (z_j - w_j \lambda_j) x_j
obtained by multiplying the raw residuals r_j
by the covariates x_j for quadrature point j.
The score residuals always sum to zero.
The result of residuals.ppm is a measure
(object of class "msr").
Use plot.msr to plot the residuals directly.
Use integral.msr to compute the total residual.
An object of class "msr"
representing a signed measure or vector-valued measure
(see msr). This object can be plotted.
.
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.
lppm,
msr,
residuals.ppm.
fit <- lppm(unmark(chicago) ~ x + y)
# raw residuals
rr <- residuals(fit)
rr
# Pearson residuals
rp <- residuals(fit, type="pe")
rp
plot(rp, main="Pearson residuals")
## multitype data
fitm <- lppm(chicago ~ (x+y) * marks, eps=100)
rpm <- residuals(fitm, type="pe")
## plot(rpm) would display 7 panels, one for each crime type
## Select residuals for crime type = Assault
plot(split(rpm)[["assault"]], markscale=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.