# relrisk.ppm

##### Parametric Estimate of Spatially-Varying Relative Risk

Given a point process model fitted to a multitype point pattern, this function computes the fitted spatially-varying probability of each type of point, or the ratios of such probabilities, according to the fitted model. Optionally the standard errors of the estimates are also computed.

##### Usage

```
# S3 method for ppm
relrisk(X, …,
at = c("pixels", "points"),
relative = FALSE, se = FALSE,
casecontrol = TRUE, control = 1, case,
ngrid = NULL, window = NULL)
```

##### Arguments

- X
A fitted point process model (object of class

`"ppm"`

).- …
Ignored.

- at
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.- se
Logical value indicating whether to compute standard errors as well.

- 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.- ngrid
Optional. Dimensions of a rectangular grid of locations inside

`window`

where the predictions should be computed. An integer, or an integer vector of length 2, specifying the number of grid points in the \(y\) and \(x\) directions. (Applies only when`at="pixels"`

.)- window
Optional. A window (object of class

`"owin"`

)*delimiting*the locations where predictions should be computed. Defaults to the window of the original data used to fit the model`object`

. (Applies only when`at="pixels"`

.)

##### Details

The command `relrisk`

is generic and can be used to
estimate relative risk in different ways.

This function `relrisk.ppm`

is the method for fitted point
process models (class `"ppm"`

). It computes *parametric*
estimates of relative risk, using the fitted model.

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 spatial location \(u\)
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 spatial location \(u\)
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 spatial location \(u\) on a fine pixel grid, and the result
is a pixel image representing the function \(p(u)\)
or a list of pixel images representing the functions
\(p_j(u)\) or \(r_j(u)\)
for \(j = 1,\ldots,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`

.

Probabilities and risks are computed from the fitted intensity of the model,
using `predict.ppm`

.
If `se=TRUE`

then standard errors will also be computed,
based on asymptotic theory, using `vcov.ppm`

.

##### Value

If `se=FALSE`

(the default), the format is described below.
If `se=TRUE`

, the result is a list of two entries,
`estimate`

and `SE`

, each having the format described below.

If `X`

consists of only two types of points,
and if `casecontrol=TRUE`

,
the result is a pixel image (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, 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`

.

##### See Also

There is another method `relrisk.ppp`

for point pattern datasets
which computes *nonparametric* estimates of relative risk
by kernel smoothing.

See also
`relrisk`

,
`relrisk.ppp`

,
`ppm`

##### Examples

```
# NOT RUN {
fit <- ppm(chorley ~ marks * (x+y))
rr <- relrisk(fit, relative=TRUE, control="lung", se=TRUE)
plot(rr$estimate)
plot(rr$SE)
rrX <- relrisk(fit, at="points", relative=TRUE, control="lung")
# }
```

*Documentation reproduced from package spatstat, version 1.52-1, License: GPL (>= 2)*