"relrisk"(X, ..., at = c("pixels", "points"), relative = FALSE, se = FALSE, casecontrol = TRUE, control = 1, case, ngrid = NULL, window = NULL)
"ppm"
).
at="pixels"
) or
only at the points of X
(at="points"
).
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.
control
in a bivariate point pattern.
Ignored if there are more than 2 types of points.
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"
.)
"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"
.)
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:
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.
at="points"
)
a matrix of probabilities, with rows corresponding to
data points $x[i]$, and columns corresponding
to types $j$.
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
.
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,...,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
.
relrisk.ppp
for point pattern datasets
which computes nonparametric estimates of relative risk
by kernel smoothing. See also
relrisk
,
relrisk.ppp
,
ppm
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")
Run the code above in your browser using DataLab