spagmix-package: The spagmix Package: Artificial Spatial and Spatiotemporal...

Description Details Dependencies/Imports Author(s) References


Provides functions to design synthetic spatial and spatiotemporal densities and relative risk functions based mainly on Gaussian mixture distributions, and simulate iid data therefrom.


Package: spagmix
Version: 0.3-1
Date: 2018-09-08
License: GPL (>= 2)

Appraisal of existing, refined, and new statistical methods for the analysis of spatial and spatiotemporal point pattern data usually involves numeric experimentation. Motivated by relevant problems in nonparametric density estimation (see e.g. Wand & Jones, 1995), spagmix (“spatial Gaussian mixtures”) provides some simple utilities for designing heterogeneous density and density-ratio or relative risk (Bithell 1990, 1991; Kelsall & Diggle, 1995) functions in space and space-time (see Fernando & Hazelton, 2014 for the latter). The package is also capable of producing realisations of (possibly inhomogeneous) spatial log-Gaussian Cox process intensities (Møller et al., 1998; see also Davies & Hazelton, 2013).

Additionally, the package contains functions for simulating datasets given these scenarios. For examples of how these kinds of synthetic functions have been used in simulation studies in various publications, see for example Clark & Lawson, 2004; Davies & Hazelton, 2010; Davies, 2013a,b; Davies & Hazelton, 2013; Fernando et al., 2014; Davies et al., 2016; Davies et al., 2018a; and Davies & Lawson, 2018.

We have designed the objects of spagmix to use and be compatible with standard object classes of the spatstat (Baddeley & Turner, 2005; Baddeley et al., 2015) and sparr (Davies et al., 2018b) packages. The content of spagmix can be broken up as follows:

Artificial polygonal windows
Some pre-made synthetic spatial windows; these are all single closed polygons as objects of class owin and are lazy-loaded:
bx, heart, shp1, shp2, star, toywin

Spatial scenarios
sgmix is used to create spatial (2D) Gaussian mixture distributions on a bounded subset of the plane.
rgmix also creates 2D Gaussian mixture densities, but does so by stochastic generation of the contributing bumps.
rrmix creates Gaussian mixture relative risk scenarios based on a supplied control density (see e.g. Davies & Hazelton, 2010). lgcpmix generates a spatial log-Gaussian Cox process intensity in space, given a deterministic intensity function and residual correlation governed by a stochastic realisation of a Gaussian field with a specified covariance structure.

Spatiotemporal scenarios
stgmix is used to create spatiotemporal (3D) Gaussian mixture densities on a bounded subset of the plane and a single closed interval in time.
stkey is used to create spatiotemporal densities by pixel-wise interpolation of multiple spatial image ‘keyframes’. rrstmix is a spatiotemporal version of rrmix, used to create artificial spatiotemporal relative risk functions. Note the control density may be purely spatial, representing a distribution ‘at-risk’ points that does not change over time (Fernando & Hazelton, 2014).

Data generation
To generate purely spatial data for a single spatial density, the user is directed to rpoint of the spatstat package or rimpoly of the sparr package.
rpoispoly is a wrapper of rimpoly, and is used to generate realisations of Poisson point processes in space, given an intensity function. rrpoint is a wrapper of rimpoly, and is used to generate iid datasets based on a synthetic spatial relative risk surface object.
rstpoint is a 3D rejection algorithm for sampling iid data from a supplied spatiotemporal density.
rrstpoint is a wrapper of rstpoint to generate iid datasets from a synthetic spatiotemporal relative risk surface object.

plot.stim is an S3 plotting method for spatiotemporal density objects.
stintegral computes the 3D integral of a spatiotemporal density object.
unify.owin is a wrapper for affine that transforms any spatial owin to fall inside the unit square.


The spagmix package depends upon spatstat (Baddeley & Turner, 2005; Baddeley et al., 2015) and imports from RandomFields (Schlather et al., 2015), abind (Plate & Heiberger, 2016), MCMCpack (Martin et al., 2011), sparr (Davies et al., 2018b), and mvtnorm (Genz et al., 2018). We also highly recommend the rgl package (Adler et al., 2018) which can be used to create interactive plots of spatiotemporal data.


A.K. Redmond and T.M. Davies
Dept. of Mathematics & Statistics, University of Otago, Dunedin, New Zealand

Maintainer: T.M.D. [email protected]


Adler, D., Murdoch, D. and others (2018), rgl: 3D Visualization Using OpenGL, R package version 0.99.16

Baddeley, A., Rubak, E. and Turner, R. (2015), Spatial Point Patterns: Methodology and Applications with R, Chapman and Hall/CRC Press, London.

Baddeley, A. and Turner, R. (2005), Spatstat: an R package for analyzing spatial point patterns, Journal of Statistical Software, 12(6), 1-42.

Bithell, J.F. (1990), An application of density estimation to geographical epidemiology, Statistics in Medicine, 9, 691-701.

Bithell, J.F. (1991), Estimation of relative risk function,. Statistics in Medicine, 10, 1745-1751.

Clark, A.B. and Lawson, A.B. (2004), An evaluation of non-parametric relative risk estimators for disease maps, Computational Statistics & Data Analysis, 47, 63-78.

Davies, T.M. (2013a), Jointly optimal bandwidth selection for the planar kernel-smoothed density-ratio, Spatial and Spatio-temporal Epidemiology, 5, 51-65.

Davies, T.M. (2013b), Scaling oversmoothing factors for kernel estimation of spatial relative risk, Epidemiological Methods, 2(1), 67-83.

Davies, T.M. and Hazelton, M.L. (2010), Adaptive kernel estimation of spatial relative risk, Statistics in Medicine, 29(23), 2423-2437.

Davies, T.M. and Hazelton, M.L. (2013), Assessing minimum contrast parameter estimation for spatial and spatiotemporal log-Gaussian Cox processes, Statistica Neerlandica, 67(4), 355-389.

Davies, T.M., Jones, K. and Hazelton, M.L. (2016), Symmetric adaptive smoothing regimens for estimation of the spatial relative risk function, Computational Statistics & Data Analysis, 101, 12-28.

Davies, T.M. and Lawson, A.B. (2018), An evaluation of likelihood-based bandwidth selectors for spatial and spatiotemporal kernel estimates, Submitted for publication.

Davies, T.M., Flynn, C.R. and Hazelton, M.L. (2018a), On the utility of asymptotic bandwidth selectors for spatially adaptive kernel density estimation, Statistics & Probability Letters, 138, 75-81.

Davies, T.M., Marshall, J.C. and Hazelton, M.L. (2018b), Tutorial on kernel estimation of continuous spatial and spatiotemporal relative risk, Statistics in Medicine, 37(7), 1191-1221.

Fernando, W.T.P.S., Ganesalingam, S. and Hazelton, M.L. (2014), A comparison of estimators of the geographical relative risk function, Journal of Statistical Computation and Simulation, 84(7), 1471-1485.

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

Genz, A., Bretz, F., Miwa, T., Mi, X., Leisch, F., Scheipl, F. and Hothorn, T. (2018), mvtnorm: Multivariate Normal and t Distributions, R package version 1.0-8. URL

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

Martin, A.D., Quinn, K.M. and Park, J.H. (2011), MCMCpack: Markov Chain Monte Carlo in R, Journal of Statistical Software 42(9), 1-21.

Møller, J., Syversveen, A.R. and Waagepetersen, R.P. (1998), Log-Gaussian Cox processes, Scandinavian Journal of Statistics, 25(3) 451–482.

Plate, T. and Heiberger, R. (2016), abind: Combine Multidimensional Arrays, R package version 1.4-5.

Schlather, M., Malinowski, A., Menck, P.J., Oesting, M. and Strokorb, K. (2015) Analysis, Simulation and Prediction of Multivariate Random Fields with Package RandomFields, Journal of Statistical Software, 63(8) 1–25.

Wand, M.P. and Jones, C.M. (1995), Kernel Smoothing, Chapman & Hall, London.

spagmix documentation built on May 2, 2019, 7:24 a.m.