Learn R Programming

spatstat.model (version 3.5-0)

predict.slrm: Predicted or Fitted Values from Spatial Logistic Regression

Description

Given a fitted Spatial Logistic Regression model, this function computes the fitted probabilities for each pixel, or the fitted point process intensity, or the values of the linear predictor in each pixel.

Usage

# S3 method for slrm
predict(object, ..., type = "intensity",
                        newdata=NULL, window=NULL,
                        leaveoneout=FALSE, fast=TRUE)

Value

A pixel image (object of class "im") containing the predicted values for each pixel.

Arguments

object

a fitted spatial logistic regression model. An object of class "slrm".

...

Optional arguments passed to pixellate determining the pixel resolution for the discretisation of the point pattern.

type

Character string (partially) matching one of "probabilities", "intensity" or "link".

newdata

Optional. List containing new covariate values for the prediction. See Details.

window

Optional. New window in which to predict. An object of class "owin".

leaveoneout

Logical value specifying whether to use leave-one-out prediction. Ignored if newdata, window or ... are given.

fast

Logical value indicating whether leave-one-out prediction should be performed using the leverage (Taylor) approximation (fast=TRUE, the default) or using brute force computation (fast=FALSE). The leverage approximation is very much faster.

Author

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner rolfturner@posteo.net and Ege Rubak rubak@math.aau.dk.

Details

This is a method for predict for spatial logistic regression models (objects of class "slrm", usually obtained from the function slrm).

The argument type determines which quantity is computed. If type="intensity"), the value of the point process intensity is computed at each pixel. If type="probabilities") the probability of the presence of a random point in each pixel is computed. If type="link", the value of the linear predictor is computed at each pixel.

If newdata = NULL (the default), the algorithm computes fitted values of the model (based on the data that was originally used to fit the model object).

If leaveoneout=TRUE, the fitted values are computed using the leave-one-out rule. To compute the fitted value at each pixel j,

  • the model object is updated by re-fitting it to the dataset excluding the data inside pixel j;

  • the predicted value at pixel j is computed from this updated model.

If newdata is given, the algorithm computes predicted values of the model, using the new values of the covariates provided by newdata. The argument newdata should be a list; names of entries in the list should correspond to variables appearing in the model formula of the object. Each list entry may be a pixel image or a single numeric value.

The argument leaveoneout is ignored if newdata or window are given, or if arguments ... specify a change of pixel resolution.

See Also

slrm

Examples

Run this code
  X <- rpoispp(42)
  fit <- slrm(X ~ x+y)
  plot(predict(fit))

  X <- copper$SouthPoints
  Y <- copper$SouthLines
  Z <- distmap(Y)
  fitc <- slrm(X ~ Z, eps=1)
  pc <- predict(fitc)
  pcminus <- predict(fitc, leaveoneout=TRUE)

  Znew <- distmap(copper$Lines)[copper$SouthWindow]
  pcnew <- predict(fitc, newdata=list(Z=Znew))

Run the code above in your browser using DataLab