spattemp.density: Spatiotemporal kernel density estimation

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/spattemp.density.R

Description

Provides a fixed-bandwidth kernel estimate of continuous spatiotemporal data.

Usage

1
2
3
spattemp.density(pp, h = NULL, tt = NULL, lambda = NULL,
  tlim = NULL, sedge = c("uniform", "none"), tedge = sedge, 
  sres = 128, tres = NULL, verbose = TRUE)

Arguments

pp

An object of class ppp giving the spatial coordinates of the observations to be smoothed. Possibly marked with the time of each event; see argument tt.

h

Fixed bandwidth to smooth the spatial margin. A numeric value > 0. If unsupplied, the oversmoothing bandwidth is used as per OS.

tt

A numeric vector of equal length to the number of points in pp, giving the time corresponding to each spatial observation. If unsupplied, the function attempts to use the values in the marks attribute of the ppp.object in pp.

lambda

Fixed bandwidth to smooth the temporal margin; a numeric value > 0. If unsupplied, the function internally computes the Sheather-Jones bandwith using bw.SJ (Sheather & Jones, 1991).

tlim

A numeric vector of length 2 giving the limits of the temporal domain over which to smooth. If supplied, all times in tt must fall within this interval (equality with limits allowed). If unsupplied, the function simply uses the range of the observed temporal values.

sedge

Character string dictating spatial edge correction. "uniform" (default) corrects based on evaluation grid coordinate. Setting sedge="none" requests no edge correction.

tedge

As sedge, for temporal edge correction.

sres

Numeric value > 0. Resolution of the [sres x sres] evaluation grid in the spatial margin.

tres

Numeric value > 0. Resolution of the evaluation points in the temporal margin as defined by the tlim interval. If unsupplied, the density is evaluated at integer values between tlim[1] and tlim[2].

verbose

Logical value indicating whether to print a function progress bar to the console during evaluation.

Details

This function produces a fixed-bandwidth kernel estimate of a single spatiotemporal density, with isotropic smoothing in the spatial margin, as per Fernando & Hazelton (2014). Estimates may be edge-corrected for an irregular spatial study window and for the bounds on the temporal margin as per tlim; this edge-correction is performed in precisely the same way as the "uniform" option in bivariate.density.

Specifically, for n trivariate points in space-time (pp, tt, tlim), we have

\hat{f}(x,t)=n^{-1}∑_{i=1}^{n}h^{-2}λ^{-1}K((x-x_i)/h)L((t-t_i)/λ)/(q(x)q(t)),

where x\in W\subset R^2 and t\in T\subset R; K and L are the 2D and 1D Gaussian kernels controlled by fixed bandwidths h (h) and λ (lambda) respectively; and q(x)=\int_W h^{-2}K((u-x)/h)du and q(t)=\int_T λ^{-1}L((w-t)/λ)dw are optional edge-correction factors (sedge and tedge).

The above equation provides the joint or unconditional density at a given space-time location (x,t). In addition to this, the function also yields the conditional density at each grid time, defined as

\hat{f}(x|t)=\hat{f}(x,t)/\hat{f}(t),

where \hat{f}(t)=n^{-1}∑_{i=1}^{n}λ^{-1}L((t-t_i)/λ)/q(t) is the univariate kernel estimate of the temporal margin. Normalisation of the two versions \hat{f}(x,t) and \hat{f}(x|t) is the only way they differ. Where in the unconditional setting we have \int_W\int_T\hat{f}(x,t)dt dx=1, in the conditional setting we have \int_W\hat{f}(x|t) dx=1 for all t. See Fernando & Hazelton (2014) for further details and practical reasons as to why we might prefer one over the other in certain situations.

The objects returned by this function (see ‘Value’ below) are necessary for kernel estimation of spatiotemporal relative risk surfaces, which is performed by spattemp.risk.

Value

An object of class "stden". This is effectively a list with the following components:

z

A named (by time-point) list of pixel images corresponding to the joint spatiotemporal density over space at each discretised time.

z.cond

A named (by time-point) list of pixel images corresponding to the conditional spatial density given each discretised time.

h

The scalar bandwidth used for spatial smoothing.

lambda

The scalar bandwidth used for temporal smoothing.

tlim

A numeric vector of length two giving the temporal bound of the density estimate.

spatial.z

A pixel image giving the overall spatial margin as a single 2D density estimate (i.e. ignoring time).

temporal.z

An object of class density giving the overall temporal margin as a single 1D density estimate (i.e. ignoring space).

qs

A pixel image giving the edge-correction surface for the spatial margin. NULL if sedge = "none".

qt

A numeric vector giving the edge-correction weights for the temporal margin. NULL if tedge = "none".

pp

A ppp.object of the spatial data passed to the argument of the same name in the initial function call, with marks of the observation times.

tgrid

A numeric vector giving the discretised time grid at which the spatiotemporal density was evaluated (matches the names of z and z.cond).

Author(s)

T.M. Davies

References

Duong, T. (2007), ks: Kernel Density Estimation and Kernel Discriminant Analysis for Multivariate Data in R, Journal of Statistical Software, 21(7), 1-16.

Fernando, W.T.P.S. and Hazelton, M.L. (2014), Generalizing the spatial relative risk function, Spatial and Spatio-temporal Epidemiology, 8, 1-10.

Kelsall, J.E. and Diggle, P.J. (1995), Kernel estimation of relative risk, Bernoulli, 1, 3-16.

Sheather, S. J. and Jones, M. C. (1991), A reliable data-based bandwidth selection method for kernel density estimation. Journal of the Royal Statistical Society Series B, 53, 683-690.

Silverman, B.W. (1986), Density Estimation for Statistics and Data Analysis, Chapman & Hall, New York.

See Also

bivariate.density, spattemp.risk, spattemp.slice

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data(burk)
burkcas <- burk$cases

burkden1 <- spattemp.density(burkcas,tres=128)
summary(burkden1)


hlam <- LIK.spattemp(burkcas,tlim=c(400,5900),verbose=FALSE)
burkden2 <- spattemp.density(burkcas,h=hlam[1],lambda=hlam[2],tlim=c(400,5900),tres=256)
tims <- c(1000,2000,3500)
par(mfcol=c(2,3))
for(i in tims){ 
  plot(burkden2,i,override.par=FALSE,fix.range=TRUE,main=paste("joint",i))
  plot(burkden2,i,"conditional",override.par=FALSE,main=paste("cond.",i))
}

sparr documentation built on March 16, 2021, 5:07 p.m.