R: Nonparametric Estimate of Spatially-Varying Relative Risk on...

relrisk.lpp {spatstat.linnet} | R Documentation

## Nonparametric Estimate of Spatially-Varying Relative Risk on a Network

### Description

Given a multitype point pattern on a linear network, this function estimates the spatially-varying probability of each type of point, or the ratios of such probabilities, using kernel smoothing.

### Usage

    ## S3 method for class 'lpp'
    relrisk(X, sigma, ...,
               at = c("pixels", "points"),
               relative=FALSE,
               adjust=1,
               casecontrol=TRUE, control=1, case,
               finespacing=FALSE)

### Arguments

`X` | A multitype point pattern (object of class `"lpp"` which has factor valued marks).
`sigma` | The numeric value of the smoothing bandwidth (the standard deviation of Gaussian smoothing kernel) passed to `density.lpp`. Alternatively `sigma` may be a function which can be used to select the bandwidth. See Details.
`...` | Arguments passed to `density.lpp` to control the pixel resolution.
`at` | Character string specifying whether to compute the probability values at a grid of pixel locations (`at="pixels"`) or only at the points of `X` (`at="points"`).
`relative` | Logical. If `FALSE` (the default) the algorithm computes the probabilities of each type of point. If `TRUE`, it computes the relative risk, the ratio of probabilities of each type relative to the probability of a control.
`adjust` | Optional. Adjustment factor for the bandwidth `sigma`.
`casecontrol` | Logical. Whether to treat a bivariate point pattern as consisting of cases and controls, and return only the probability or relative risk of a case. Ignored if there are more than 2 types of points. See Details.
`control` | Integer, or character string, identifying which mark value corresponds to a control.
`case` | Integer, or character string, identifying which mark value corresponds to a case (rather than a control) in a bivariate point pattern. This is an alternative to the argument `control` in a bivariate point pattern. Ignored if there are more than 2 types of points.
`finespacing` | Logical value specifying whether to use a finer spatial resolution (with longer computation time but higher accuracy).

### Details

The command `relrisk` is generic and can be used to estimate relative risk in different ways.

This function `relrisk.lpp` is the method for point patterns on a linear network (objects of class `"lpp"`). It computes nonparametric estimates of relative risk by kernel smoothing.

If `X` is a bivariate point pattern (a multitype point pattern consisting of two types of points) then by default, the points of the first type (the first level of `marks(X)`) are treated as controls or non-events, and points of the second type are treated as cases or events. Then by default this command computes the spatially-varying probability of a case, i.e. the probability p(u) that a point at location u on the network will be a case. If `relative=TRUE`, it computes the spatially-varying relative risk of a case relative to a control, r(u) = p(u)/(1- p(u)).

If `X` is a multitype point pattern with m > 2 types, or if `X` is a bivariate point pattern and `casecontrol=FALSE`, then by default this command computes, for each type j, a nonparametric estimate of the spatially-varying probability of an event of type j. This is the probability p[j](u) that a point at location u on the network will belong to type j. If `relative=TRUE`, the command computes the relative risk of an event of type j relative to a control, r[j](u) = p[j](u)/p[k](u), where events of type k are treated as controls. The argument `control` determines which type k is treated as a control.

If `at = "pixels"` the calculation is performed for every location u on a fine pixel grid over the network, and the result is a pixel image on the network representing the function p(u), or a list of pixel images representing the functions p[j](u) or r[j](u) for j = 1,...,m. An infinite value of relative risk (arising because the probability of a control is zero) will be returned as `NA`.

If `at = "points"` the calculation is performed only at the data points x[i]. By default the result is a vector of values p(x[i]) giving the estimated probability of a case at each data point, or a matrix of values p[j](x[i]) giving the estimated probability of each possible type j at each data point. If `relative=TRUE` then the relative risks r(x[i]) or r[j](x[i]) are returned. An infinite value of relative risk (arising because the probability of a control is zero) will be returned as `Inf`.

Estimation is performed by a Nadaraja-Watson type kernel smoother (McSwiggan et al., 2019).

The smoothing bandwidth `sigma` should be a single numeric value, giving the standard deviation of the isotropic Gaussian kernel. If `adjust` is given, the smoothing bandwidth will be `adjust * sigma` before the computation of relative risk.

Alternatively, `sigma` may be a function that can be applied to the point pattern `X` to select a bandwidth; the function must return a single numerical value; examples include the functions `bw.relrisklpp` and `bw.scott.iso`.

Accuracy depends on the spatial resolution of the density computations. If the arguments `dx` and `dt` are present, they are passed to `density.lpp` to determine the spatial resolution. Otherwise, the spatial resolution is determined by a default rule that depends on `finespacing` and `sigma`. If `finespacing=FALSE` (the default), the spatial resolution is equal to the default resolution for pixel images. If `finespacing=TRUE`, the spatial resolution is much finer and is determined by a rule which guarantees higher accuracy, but takes a longer time.

### Value

If `X` consists of only two types of points, and if `casecontrol=TRUE`, the result is a pixel image on the network (if `at="pixels"`) or a vector (if `at="points"`). The pixel values or vector values are the probabilities of a case if `relative=FALSE`, or the relative risk of a case (probability of a case divided by the probability of a control) if `relative=TRUE`.

If `X` consists of more than two types of points, or if `casecontrol=FALSE`, the result is:

- (if `at="pixels"`) a list of pixel images on the network, with one image for each possible type of point. The result also belongs to the class `"solist"` so that it can be printed and plotted.

- (if `at="points"`) a matrix of probabilities, with rows corresponding to data points x[i], and columns corresponding to types j.

The pixel values or matrix entries are the probabilities of each type of point if `relative=FALSE`, or the relative risk of each type (probability of each type divided by the probability of a control) if `relative=TRUE`.

If `relative=FALSE`, the resulting values always lie between 0 and 1. If `relative=TRUE`, the results are either non-negative numbers, or the values `Inf` or `NA`.

### Author(s)

Greg McSwiggan and Adrian Baddeley Adrian.Baddeley@curtin.edu.au.

### References

McSwiggan, G., Baddeley, A. and Nair, G. (2019) Estimation of relative risk for events on a linear network. Statistics and Computing 30 (2) 469–484.

### See Also

`relrisk`

### Examples

       ## case-control data: 2 types of points
       set.seed(2020)
       X <- superimpose(A=runiflpp(20, simplenet),
                        B=runifpointOnLines(20, as.psp(simplenet)[1]))
       plot(X)
       plot(relrisk(X, 0.2))
       plot(relrisk(X, 0.2, case="B"))
       head(relrisk(X, 0.2, at="points"))
       ## cross-validated bandwidth selection
       plot(relrisk(X, bw.relrisklpp, hmax=0.3))

       ## more than 2 types
       if(interactive()) {
         U <- chicago
         sig <- 170
       } else {
         U <- do.call(superimpose,
                      split(chicago)[c("theft", "cartheft", "burglary")])
         sig <- 50
       }
       plot(relrisk(U, sig))
       head(relrisk(U, sig, at="points"))
       plot(relrisk(U, sig, relative=TRUE, control="theft"))

[Package spatstat.linnet version 2.0-0 Index]