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

View source: R/spattemp.density.R

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

1 2 3 |

`pp` |
An object of class |

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

`tt` |
A numeric vector of equal length to the number of points in |

`lambda` |
Fixed bandwidth to smooth the temporal margin; a numeric value > 0. If unsupplied, the function internally computes the Sheather-Jones bandwith using |

`tlim` |
A numeric vector of length 2 giving the limits of the temporal domain over which to smooth. If supplied, all times in |

`sedge` |
Character string dictating spatial edge correction. |

`tedge` |
As |

`sres` |
Numeric value > 0. Resolution of the [ |

`tres` |
Numeric value > 0. Resolution of the evaluation points in the temporal margin as defined by the |

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

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`

.

An object of class `"stden"`

. This is effectively a list with the following components:

`z` |
A named (by time-point) list of pixel |

`z.cond` |
A named (by time-point) list of pixel |

`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 |

`temporal.z` |
An object of class |

`qs` |
A pixel |

`qt` |
A numeric vector giving the edge-correction weights for the temporal margin. |

`pp` |
A |

`tgrid` |
A numeric vector giving the discretised time grid at which the spatiotemporal density was evaluated (matches the names of |

T.M. Davies

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.

`bivariate.density`

, `spattemp.risk`

, `spattemp.slice`

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))
}
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.