spattemp.risk {sparr} | R Documentation |
Spatiotemporal relative risk/density ratio
Description
Produces a spatiotemporal relative risk surface based on the ratio of two kernel estimates of spatiotemporal densities.
Usage
spattemp.risk(f, g, log = TRUE, tolerate = FALSE, finiteness = TRUE, verbose = TRUE)
Arguments
f |
An object of class |
g |
Either an object of class |
log |
Logical value indicating whether to return the log relative risk (default) or the raw ratio. |
tolerate |
Logical value indicating whether to compute and return asymptotic |
finiteness |
Logical value indicating whether to internally correct infinite risk (on the log-scale) to the nearest finite value to avoid numerical problems. A small extra computational cost is required. |
verbose |
Logical value indicating whether to print function progress during execution. |
Details
Fernando & Hazelton (2014) generalise the spatial relative risk function (e.g. Kelsall & Diggle, 1995) to the spatiotemporal domain. This is the implementation of their work, yielding the generalised log-relative risk function for and
. It produces
where is a fixed-bandwidth kernel estimate of the spatiotemporal density of the cases (argument
f
) and is the same for the controls (argument
g
).
When argument
g
is an object of classstden
arising from a call tospattemp.density
, the resolution, spatial domain, and temporal domain of this spatiotemporal estimate must match that off
exactly, else an error will be thrown.When argument
g
is an object of classbivden
arising from a call tobivariate.density
, it is assumed the ‘at-risk’ control density is static over time. In this instance, the above equation for the relative risk becomes. The spatial density estimate in
g
must match the spatial domain off
exactly, else an error will be thrown.The estimate
represents the joint or unconditional spatiotemporal relative risk over
. This means that the raw relative risk
integrates to 1 with respect to the control density over space and time:
. This function also computes the conditional spatiotemporal relative risk at each time point, namely
where
and
are the conditional densities over space of the cases and controls given a specific time point
(see the documentation for
spattemp.density
). In terms of normalisation, we therefore have. In the case where
is static over time, one may simply replace
with
in the above.
Based on the asymptotic properties of the estimator, Fernando & Hazelton (2014) also define the calculation of tolerance contours for detecting statistically significant fluctuations in such spatiotemporal log-relative risk surfaces. This function can produce the required
-value surfaces by setting
tolerate = TRUE
; and if so, results are returned for both the unconditional (x,t) and conditional (x|t) surfaces. See the examples in the documentation forplot.rrst
for details on how one may superimpose contours at specific-values for given evaluation times
on a plot of relative risk on the spatial margin.
Value
An object of class “rrst
”. This is effectively a list with the following members:
rr |
A named (by time-point) list of pixel |
rr.cond |
A named list of pixel |
P |
A named list of pixel |
P.cond |
As above, for the conditional relative risk surfaces. |
f |
A copy of the object |
g |
As above, for |
tlim |
A numeric vector of length two giving the temporal bound of the density estimate. |
Author(s)
T.M. Davies
References
Fernando, W.T.P.S. and Hazelton, M.L. (2014), Generalizing the spatial relative risk function, Spatial and Spatio-temporal Epidemiology, 8, 1-10.
See Also
spattemp.density
, spattemp.slice
, bivariate.density
Examples
data(fmd)
fmdcas <- fmd$cases
fmdcon <- fmd$controls
f <- spattemp.density(fmdcas,h=6,lambda=8) # stden object as time-varying case density
g <- bivariate.density(fmdcon,h0=6) # bivden object as time-static control density
rho <- spattemp.risk(f,g,tolerate=TRUE)
print(rho)
oldpar <- par(mfrow=c(2,3))
plot(rho$f$spatial.z,main="Spatial margin (cases)") # spatial margin of cases
plot(rho$f$temporal.z,main="Temporal margin (cases)") # temporal margin of cases
plot(rho$g$z,main="Spatial margin (controls)") # spatial margin of controls
plot(rho,tselect=50,type="conditional",tol.args=list(levels=c(0.05,0.0001),
lty=2:1,lwd=1:2),override.par=FALSE)
plot(rho,tselect=100,type="conditional",tol.args=list(levels=c(0.05,0.0001),
lty=2:1,lwd=1:2),override.par=FALSE)
plot(rho,tselect=200,type="conditional",tol.args=list(levels=c(0.05,0.0001),
lty=2:1,lwd=1:2),override.par=FALSE)
par(oldpar)