spatstat (version 1.23-5)

Kcom: Model Compensator of K Function

Description

Given a point process model fitted to a point pattern dataset, this function computes the compensator of the $K$ function based on the fitted model (as well as the usual nonparametric estimates of $K$ based on the data alone). Comparison between the nonparametric and model-compensated $K$ functions serves as a diagnostic for the model.

Usage

Kcom(object, r = NULL, breaks = NULL, ...,
     correction = c("border", "isotropic", "translate"),
     restrict = FALSE,
     trend = ~1, interaction = Poisson(), rbord = reach(interaction),
     compute.var = TRUE,
     truecoef = NULL, hi.res = NULL)

Arguments

object
Object to be analysed. Either a fitted point process model (object of class "ppm") or a point pattern (object of class "ppp") or quadrature scheme (object of class "quad").
r
Optional. Vector of values of the argument $r$ at which the function $K(r)$ should be computed. This argument is usually not specified. There is a sensible default.
breaks
Optional alternative to r for advanced use.
...
Ignored.
correction
Optional vector of character strings specifying the edge correction(s) to be used. See Kest for options.
restrict
Logical value indicating whether to compute the restriction estimator (restrict=TRUE) or the reweighting estimator (restrict=FALSE, the default). See Details.
trend,interaction,rbord
Optional. Arguments passed to ppm to fit a point process model to the data, if object is a point pattern. See ppm for details.
compute.var
Logical value indicating whether to compute the Poincare variance bound for the residual $K$ function (calculation is only implemented for the isotropic correction).
truecoef
Optional. Numeric vector. If present, this will be treated as if it were the true coefficient vector of the point process model, in calculating the diagnostic. Incompatible with hi.res.
hi.res
Optional. List of parameters passed to quadscheme. If this argument is present, the model will be re-fitted at high resolution as specified by these parameters. The coefficients of the re

Value

  • 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.

Details

This command provides a diagnostic for the goodness-of-fit of a point process model fitted to a point pattern dataset. It computes an estimate of the $K$ function of the dataset, together with a model compensator of the $K$ function, which should be approximately equal if the model is a good fit to the data.

The first argument, object, is usually a fitted point process model (object of class "ppm"), obtained from the model-fitting function ppm.

For convenience, object can also be a point pattern (object of class "ppp"). In that case, a point process model will be fitted to it, by calling ppm using the arguments trend (for the first order trend), interaction (for the interpoint interaction) and rbord (for the erosion distance in the border correction for the pseudolikelihood). See ppm for details of these arguments.

The algorithm first extracts the original point pattern dataset (to which the model was fitted) and computes the standard nonparametric estimates of the $K$ function. It then also computes the model compensator of the $K$ function. The different function estimates are returned as columns in a data frame (of class "fv").

The argument correction determines the edge correction(s) to be applied. See Kest for explanation of the principle of edge corrections. The following table gives the options for the correction argument, and the corresponding column names in the result:

llll{ correction description of correction nonparametric compensator "isotropic" Ripley isotropic correction iso icom "translate" Ohser-Stoyan translation correction trans tcom "border" border correction border bcom }

The nonparametric estimates can all be expressed in the form $$\hat K(r) = \sum_i \sum_{j < i} e(x_i,x_j,r,x) I{ d(x_i,x_j) \le r }$$ where $x_i$ is the $i$-th data point, $d(x_i,x_j)$ is the distance between $x_i$ and $x_j$, and $e(x_i,x_j,r,x)$ is a term that serves to correct edge effects and to re-normalise the sum. The corresponding model compensator is $${\bf C} \, \tilde K(r) = \int_W \lambda(u,x) \sum_j e(u,x_j,r,x \cup u) I{ d(u,x_j) \le r}$$ where the integral is over all locations $u$ in the observation window, $\lambda(u,x)$ denotes the conditional intensity of the model at the location $u$, and $x \cup u$ denotes the data point pattern $x$ augmented by adding the extra point $u$. If the fitted model is a Poisson point process, then the formulae above are exactly what is computed. If the fitted model is not Poisson, the formulae above are modified slightly to handle edge effects. The modification is determined by the argument restrict. If restrict=TRUE the algorithm calculates the restriction estimator; if restrict=FALSE it calculates the reweighting estimator. See Appendix D of Baddeley, Rubak and Moller (2011). The nonparametric estimates of $K(r)$ are approximately unbiased estimates of the $K$-function, assuming the point process is stationary. The model compensators are unbiased estimates of the mean values of the corresponding nonparametric estimates, assuming the model is true. Thus, if the model is a good fit, the mean value of the difference between the nonparametric estimates and model compensators is approximately zero.

References

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

See Also

Kres, Kest, ppm

Examples

Run this code
data(cells)
    fit0 <- ppm(cells, ~1) # uniform Poisson
    plot(Kcom(fit0))
# compare the isotropic-correction estimates
    plot(Kcom(fit0), cbind(iso, icom) ~ r)
# uniform Poisson is clearly not correct

    fit1 <- ppm(cells, ~1, Strauss(0.08))
    K1 <- Kcom(fit1)
    K1
    plot(K1)
    plot(K1, cbind(iso, icom) ~ r)
    plot(K1, cbind(trans, tcom) ~ r)
# how to plot the difference between nonparametric estimates and compensators
    plot(K1, iso - icom ~ r)
# fit looks approximately OK; try adjusting interaction distance

    fit2 <- ppm(cells, ~1, Strauss(0.12))
    K2 <- Kcom(fit2)
    plot(K2)
    plot(K2, cbind(iso, icom) ~ r)
    plot(K2, iso - icom ~ r)

Run the code above in your browser using DataCamp Workspace