Learn R Programming

spatstat.core (version 2.3-1)

addvar: Added Variable Plot for Point Process Model

Description

Computes the coordinates for an Added Variable Plot for a fitted point process model.

Usage

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

Arguments

model

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

covariate

The covariate to be added to the model. Either a pixel image, a function(x,y), or a character string giving the name of a covariate that was supplied when the model was fitted.

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.

crosscheck

For developers only. Logical value indicating whether to perform cross-checks on the validity of the calculation.

Value

An object of class "addvar" containing the coordinates for the added variable plot. There is a plot method.

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

Internal data

The return value has an attribute "spatial" which contains the internal data: the computed values of the residuals, and of all relevant covariates, at each quadrature point of the model. It is an object of class "ppp" with a data frame of marks.

Details

This command generates the plot coordinates for an Added Variable Plot for a spatial point process model.

Added Variable Plots (Cox, 1958, sec 4.5; Wang, 1985) are commonly used in linear models and generalized linear models, to decide whether a model with response \(y\) and predictors \(x\) would be improved by including another predictor \(z\).

In a (generalised) linear model with response \(y\) and predictors \(x\), the Added Variable Plot for a new covariate \(z\) is a plot of the smoothed Pearson residuals from the original model against the scaled residuals from a weighted linear regression of \(z\) on \(x\). If this plot has nonzero slope, then the new covariate \(z\) is needed. For general advice see Cook and Weisberg(1999); Harrell (2001).

Essentially the same technique can be used for a spatial point process model (Baddeley et al, 2012).

The argument model should be a fitted spatial point process model (object of class "ppm").

The argument covariate identifies the covariate that is to be considered for addition to the model. It should be either a pixel image (object of class "im") or a function(x,y) giving the values of the covariate at any spatial location. Alternatively covariate may be a character string, giving the name of a covariate that was supplied (in the covariates argument to ppm) when the model was fitted, but was not used in the model.

The result of addvar(model, covariate) is an object belonging to the classes "addvar" and "fv". Plot this object to generate the added variable plot.

Note that the plot method shows the pointwise significance bands for a test of the null model, i.e. the null hypothesis that the new covariate has no effect.

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.

Cook, R.D. and Weisberg, S. (1999) Applied regression, including computing and graphics. New York: Wiley.

Cox, D.R. (1958) Planning of Experiments. New York: Wiley.

Harrell, F. (2001) Regression Modeling Strategies. New York: Springer.

Wang, P. (1985) Adding a variable in generalized linear models. Technometrics 27, 273--276.

See Also

parres, rhohat, rho2hat.

Examples

Run this code
# NOT RUN {
  X <-  rpoispp(function(x,y){exp(3+3*x)})
  model <- ppm(X, ~y)
  adv <- addvar(model, "x")
  plot(adv)
  adv <- addvar(model, "x", subregion=square(0.5))
# }

Run the code above in your browser using DataLab