spatstat (version 1.51-0)

parres: Partial Residuals for Point Process Model

Description

Computes the smoothed partial residuals, a diagnostic for transformation of a covariate in a Poisson point process model.

Usage

parres(model, covariate, ...,
       smooth.effect=FALSE, subregion=NULL,
       bw = "nrd0", adjust=1, from = NULL, to = NULL, n = 512,
       bw.input = c("points", "quad"), bw.restrict=FALSE, covname)

Arguments

model

Fitted point process model (object of class "ppm").

covariate

The covariate of interest. Either a character string matching the name of one of the canonical covariates in the model, or one of the names "x" or "y" referring to the Cartesian coordinates, or one of the names of the covariates given when model was fitted, or a pixel image (object of class "im") or function(x,y) supplying the values of a covariate at any location.

smooth.effect

Logical. Determines the choice of algorithm. See Details.

subregion

Optional. A window (object of class "owin") specifying a subset of the spatial domain of the data. The calculation will be confined to the data in this subregion.

bw

Smoothing bandwidth or bandwidth rule (passed to density.default).

adjust

Smoothing bandwidth adjustment factor (passed to density.default).

n, from, to

Arguments passed to density.default to control the number and range of values at which the function will be estimated.

Additional arguments passed to density.default.

bw.input

Character string specifying the input data used for automatic bandwidth selection.

bw.restrict

Logical value, specifying whether bandwidth selection is performed using data from the entire spatial domain or from the subregion.

covname

Optional. Character string to use as the name of the covariate.

Value

A function value table (object of class "fv") containing the values of the smoothed partial residual, the estimated variance, and the fitted effect of the covariate. Also belongs to the class "parres" which has methods for print and plot.

Slow computation

In a large dataset, computation can be very slow if the default settings are used, because the smoothing bandwidth is selected automatically. To avoid this, specify a numerical value for the bandwidth bw. One strategy is to use a coarser subset of the data to select bw automatically. The selected bandwidth can be read off the print output for parres.

Details

This command computes the smoothed partial residual diagnostic (Baddeley, Chang, Song and Turner, 2012) for the transformation of a covariate in a Poisson point process model.

The argument model must be a fitted Poisson point process model.

The diagnostic works in two different ways:

Canonical covariate:

The argument covariate may be a character string which is the name of one of the canonical covariates in the model. The canonical covariates are the functions \(Z_j\) that appear in the expression for the Poisson point process intensity $$ \lambda(u) = \exp(\beta_1 Z_1(u) + \ldots + \beta_p Z_p(u)) $$ at spatial location \(u\). Type names(coef(model)) to see the names of the canonical covariates in model. If the selected covariate is \(Z_j\), then the diagnostic plot concerns the model term \(\beta_j Z_j(u)\). The plot shows a smooth estimate of a function \(h(z)\) that should replace this linear term, that is, \(\beta_j Z_j(u)\) should be replaced by \(h(Z_j(u))\). The linear function is also plotted as a dotted line.

New covariate:

If the argument covariate is a pixel image (object of class "im") or a function(x,y), it is assumed to provide the values of a covariate that is not present in the model. Alternatively covariate can be the name of a covariate that was supplied when the model was fitted (i.e. in the call to ppm) but which does not feature in the model formula. In either case we speak of a new covariate \(Z(u)\). If the fitted model intensity is \(\lambda(u)\) then we consider modifying this to \(\lambda(u) \exp(h(Z(u)))\) where \(h(z)\) is some function. The diagnostic plot shows an estimate of \(h(z)\). Warning: in this case the diagnostic is not theoretically justified. This option is provided for research purposes.

Alternatively covariate can be one of the character strings "x" or "y" signifying the Cartesian coordinates. The behaviour here depends on whether the coordinate was one of the canonical covariates in the model.

If there is more than one canonical covariate in the model that depends on the specified covariate, then the covariate effect is computed using all these canonical covariates. For example in a log-quadratic model which includes the terms x and I(x^2), the quadratic effect involving both these terms will be computed.

There are two choices for the algorithm. If smooth.effect=TRUE, the fitted covariate effect (according to model) is added to the point process residuals, then smoothing is applied to these values. If smooth.effect=FALSE, the point process residuals are smoothed first, and then the fitted covariate effect is added to the result.

The smoothing bandwidth is controlled by the arguments bw, adjust, bw.input and bw.restrict. If bw is a numeric value, then the bandwidth is taken to be adjust * bw. If bw is a string representing a bandwidth selection rule (recognised by density.default) then the bandwidth is selected by this rule.

The data used for automatic bandwidth selection are specified by bw.input and bw.restrict. If bw.input="points" (the default) then bandwidth selection is based on the covariate values at the points of the original point pattern dataset to which the model was fitted. If bw.input="quad" then bandwidth selection is based on the covariate values at every quadrature point used to fit the model. If bw.restrict=TRUE then the bandwidth selection is performed using only data from inside the subregion.

References

Baddeley, A., Chang, Y.-M., Song, Y. and Turner, R. (2013) Residual diagnostics for covariate effects in spatial point process models. Journal of Computational and Graphical Statistics, 22, 886--905.

See Also

addvar, rhohat, rho2hat

Examples

Run this code
# NOT RUN {
  X <-  rpoispp(function(x,y){exp(3+x+2*x^2)})
  model <- ppm(X, ~x+y)
  tra <- parres(model, "x")
  plot(tra)
  plot(parres(model, "x", subregion=square(0.5)))
  model2 <- ppm(X, ~x+I(x^2)+y)
  plot(parres(model2, "x"))
  Z <- setcov(owin())
  plot(parres(model2, Z))
# }

Run the code above in your browser using DataCamp Workspace