spatstat.core (version 2.1-2)

Gres: Residual G Function


Given a point process model fitted to a point pattern dataset, this function computes the residual \(G\) function, which serves as a diagnostic for goodness-of-fit of the model.


Gres(object, ...)



Object to be analysed. Either a fitted point process model (object of class "ppm"), a point pattern (object of class "ppp"), a quadrature scheme (object of class "quad"), or the value returned by a previous call to Gcom.

Arguments passed to Gcom.


A function value table (object of class "fv"), essentially a data frame of function values. There is a plot method for this class. See fv.object.


This command provides a diagnostic for the goodness-of-fit of a point process model fitted to a point pattern dataset. It computes a residual version of the \(G\) function of the dataset, which should be approximately zero if the model is a good fit to the data.

In normal use, object is a fitted point process model or a point pattern. Then Gres first calls Gcom to compute both the nonparametric estimate of the \(G\) function and its model compensator. Then Gres computes the difference between them, which is the residual \(G\)-function.

Alternatively, object may be a function value table (object of class "fv") that was returned by a previous call to Gcom. Then Gres computes the residual from this object.


Baddeley, A., Rubak, E. and Moller, J. (2011) Score, pseudo-score and residual diagnostics for spatial point process models. Statistical Science 26, 613--646.

See Also

Related functions: Gcom, Gest.

Alternative functions: Kres, psstA, psstG, psst.

Model-fitting: ppm.


    fit0 <- ppm(cells, ~1) # uniform Poisson
    G0 <- Gres(fit0)
# Hanisch correction estimate
    plot(G0, hres ~ r)
# uniform Poisson is clearly not correct

    fit1 <- ppm(cells, ~1, Strauss(0.08))
    plot(Gres(fit1), hres ~ r)
# fit looks approximately OK; try adjusting interaction distance

    plot(Gres(cells, interaction=Strauss(0.12)))

# How to make envelopes
    if(interactive()) {
      E <- envelope(fit1, Gres, model=fit1, nsim=39)
# For computational efficiency
    Gc <- Gcom(fit1)
    G1 <- Gres(Gc)
# }