Learn R Programming

surveillance (version 1.5-4)

twinstim_iaf: Temporal and Spatial Interaction Functions for twinstim

Description

A twinstim model as described in Meyer et al. (2012) requires the specification of the spatial and temporal interaction functions ($f$ and $g$, respectively), i.e. how infectivity decays with increasing spatial and temporal distance from the source of infection. It is of course possible to define own functions (which are implemented as list objects with required components described in the Value section below), but the package also predefines some dispersal kernels returned by the constructor functions documented here.

Usage

# predefined spatial interaction functions
siaf.constant()
siaf.gaussian(nTypes = 1, logsd = TRUE, density = FALSE, F.adaptive = TRUE,
              effRangeMult = 6, validpars = NULL)
siaf.lomax(nTypes = 1, logpars = TRUE, density = FALSE,
           effRangeProb = NULL, validpars = NULL)
siaf.powerlaw(nTypes = 1, logpars = TRUE,
              effRangeProb = NULL, validpars = NULL)
siaf.powerlawL(nTypes = 1, logpars = TRUE,
               effRangeProb = NULL, validpars = NULL)

# predefined temporal interaction functions tiaf.constant() tiaf.exponential(nTypes = 1)

Arguments

nTypes
determines the number of parameters ((log-)scales or (log-)shapes) of the kernels. In a multitype epidemic, the different types may share the same spatial interaction function, in which case nTypes=1. Otherwise nTypes
logsd, logpars
logical indicating if the kernel should be parametrized with the log-standard deviation (or log(scale) and log(shape)) as the parameter(s) in question to enforce positivity. This is the recommended default and avoids constrained optimisation
density
logical. If TRUE, a density is used as the interaction function: for siaf.gaussian, the density of the bivariate, isotropic normal distribution, for siaf.lomax, $f(||\bold{s}||)$ is the density of the (un
F.adaptive
If F.adaptive = TRUE, then an adaptive bandwidth of adapt*sd will be used in the midpoint-cubature (see polyCub.midpoint) of the Gaussian interaction kernel, w
effRangeMult
determines the effective range for numerical integration in terms of multiples of the standard deviation $\sigma$ of the Gaussian kernel, i.e. with effRangeMult=6 numerical integration only considers the $6 \sigma$ area around the
effRangeProb
numeric scalar in $(0,1)$, which determines the effective range for numerical integration in terms of the corresponding quantile of the univariate Lomax distribution. May also be NULL (default), which disables the integral approxi
validpars
function taking one argument, the parameter vector, indicating if it is valid. If logsd=FALSE or logpars=FALSE and one prefers not to use method="L-BFGS-B" for fitting the twinstim, then

Value

  • The specification of an interaction function, which is a list. For spatial kernels, this list contains the following components:
  • fspatial interaction function (siaf). It must accept two arguments, the first one being a (2-column) coordinate matrix, the second one a parameter vector. For marked twinstim, it must accept the type of the event (integer code) as its third argument (either a single type for all locations or separate types for each location).
  • Ffunction computing the integral of $f(s)$ (passed as second argument) over a polygonal "owin" domain (first argument). The third and fourth argument are the parameter vector and the (single) type, respectively. There may be additional arguments, which can then be specified in the control.siaf$F argument list of twinstim. If this function is missing, a general default (polyCub) will be used, with extra arguments method (default: "SV") and corresponding accuracy parameters.
  • Fcircleoptional function for fast calculation of the (two-dimensional) integral of $f(s)$ over a circle with radius r (first argument). Further arguments are as for f. It must not be vectorized (will always be called with single radius and a single type). If this function is specified, integration of the siaf over the spatial influence region of an event will be faster if the region is actually circular. This is the case if the event is located at least a distance eps.s from the border of the observation region W, or if the distance to the border is larger than the effective integration range (if specified, see effRange below).
  • effRangeoptional function returning the effective range of $f(s)$ for the given set of parameters (the first and only argument) such that the circle with radius effRange contains the numerically essential proportion of the integral mass. For the Gaussian kernel the default is function (logsd) 6*exp(logsd). The return value must be a vector of length nTypes (effective range for each type). This function is only used if Fcircle is also specified.
  • derivoptional derivative of $f(s)$ with respect to the parameters. It takes the same arguments as f but returns a matrix with as many rows as there were coordinates in the input and npars columns. This derivative is necessary for the calculation of the score function in twinstim(), which is advantageous for the numerical log-likelihood maximization.
  • Derivfunction computing the integral of deriv (passed as second argument) over a polygonal "owin" domain (first argument). The third and fourth argument are the parameter vector and the (single) type, respectively. There may be additional arguments, which can then be specified in the control.siaf$Deriv argument list of twinstim. If this function is missing, a general default (polyCub) will be used, with extra arguments method (default: "SV") and corresponding accuracy parameters.
  • simulateoptional function returning a sample drawn from the spatial kernel (only required for the simulation of twinstim models). Its first argument is the size of the sample to generate, further arguments are as for f (but the optional third argument specifies a single event type only). The function must return a two-column matrix of the sampled locations. Note that the simulation method actually samples only one location at a time, thus it is sufficient to have a working function(n=1, pars, type).
  • nparsthe number of parameters of the spatial interaction function f (i.e. the length of its second argument).
  • For temporal kernels, the components are:
  • gtemporal interaction function (tiaf). It must accept two arguments, the first one being a vector of time points, the second one a parameter vector. For marked twinstim, it must accept the type of the event (integer code) as its third argument (either a single type for all locations or separate types for each location).
  • Ga primitive of $g(t)$ (with respect to time). It must accept the same arguments as g, for instance a vector of time points (not just a single one).
  • derivoptional derivative of $g(t)$ with respect to the parameters. It takes the same arguments as g but returns a matrix with as many rows as there were time points in the input and npars columns. This derivative is necessary for the calculation of the score function in twinstim(), which is advantageous for the numerical log-likelihood maximization.
  • Derivoptional primitive of deriv (with respect to time). It must accept the same arguments as deriv, g and G and returns a matrix with as many rows as there were time points in the input and npars columns. The integrated derivative is necessary for the score function in twinstim.
  • nparsthe number of parameters of the temporal interaction function g (i.e. the length of its second argument).
  • In both cases, there may be an additional component validpars as a way to specify parameter constraints:
  • validparsoptional function taking one argument, the parameter vector, indicating if it is valid. This function is rarely needed in practice, because usual box-constrained parameters can be taken into account by using L-BFGS-B as the optimization method in twinstim (with arguments lower and upper), and positivity constraints by using log-parametrizations. This component is not necessary (and ignored) if npars == 0.

encoding

latin1

Details

The readily available spatial interaction functions are defined as follows: [object Object],[object Object],[object Object],[object Object],[object Object] Furthermore, there are two predefined temporal interaction functions: [object Object],[object Object]

References

Meyer, S., Elias, J. and H{oe}hle, M. (2012): A space-time conditional intensity model for invasive meningococcal disease occurrence. Biometrics, 68, 607-616. DOI-Link: http://dx.doi.org/10.1111/j.1541-0420.2011.01684.x

Meyer, S. (2010): Spatio-Temporal Infectious Disease Epidemiology based on Point Processes. Master's Thesis, Ludwig-Maximilians-Universit{ae}t M{ue}nchen. Available as http://epub.ub.uni-muenchen.de/11703/

See Also

twinstim.

Examples

Run this code
# constant temporal dispersal
tiaf.constant()

# Type-dependent Gaussian spatial interaction function using an adaptive
# two-dimensional midpoint-rule to integrate it over polygonal domains
siaf.gaussian(2, F.adaptive=TRUE)

# Type-independent power-law kernel
siaf.powerlaw()   # siaf.lomax() is deprecated

# "lagged" power-law
siaf.powerlawL()

Run the code above in your browser using DataLab