Given a spatial logistic regression model fitted to a point pattern, compute the residuals for each pixel.
# S3 method for slrm
residuals(object,
type=c("raw", "deviance", "pearson", "working",
"response", "partial", "score"),
...)A pixel image (if the residual values are scalar), or a list of pixel images (if the residual values are vectors).
The fitted point process model (an object of class "ppm")
for which residuals should be calculated.
String (partially matched) indicating the type of residuals to be calculated.
Ignored.
Adrian Baddeley Adrian.Baddeley@curtin.edu.au
This function computes several kinds of residuals for the fit of a spatial logistic regression model to a spatial point pattern dataset.
The argument object must be a fitted spatial logistic
regression model (object of class "slrm"). Such objects are
created by the fitting algorithm slrm.
The residuals are computed for each pixel that was used to fit the original model. The residuals are returned as a pixel image (if the residual values are scalar), or a list of pixel images (if the residual values are vectors).
The type of residual is chosen by the argument type.
For a given pixel, suppose \(p\) is the fitted probability of presence of a point, and \(y\) is the presence indicator (equal to 1 if the pixel contains any data points, and equal to 0 otherwise). Then
type="raw" or type="response" specifies
the response residual
$$r = y - p$$
type="pearson" is the Pearson residual
$$
r_P = \frac{y - p}{\sqrt{p (1-p)}}
$$
type="deviance" is the deviance residual
$$
r_D = (-1)^{y+1} \sqrt{-2(y log p + (1-y) log(1-p))}
$$
type="score" specifies the score residuals
$$
r_S = (y-p) x
$$
where x is the vector of canonical covariate values
for the pixel
type="working" specifies the working residuals
as defined in residuals.glm
type="partial" specifies the partial residuals
as defined in residuals.glm
residuals.glm,
residuals.ppm
d <- if(interactive()) 128 else 32
H <- unmark(humberside)
fit <- slrm(H ~ x + y, dimyx=d)
plot(residuals(fit))
plot(residuals(fit, type="score"))
Run the code above in your browser using DataLab