twinstimtwinstim 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
  # 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)
nTypes=1. Otherwise nTypesTRUE, 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 (unF.adaptive = TRUE, then an adaptive bandwidth of
    adapt*sd will be used in the midpoint-cubature
    (see polyCub.midpoint) of the Gaussian interaction
    kernel, weffRangeMult=6 numerical
    integration only considers the $6 \sigma$ area around theNULL (default),
    which disables the integral approxilogsd=FALSE or logpars=FALSE and one
    prefers not to use method="L-BFGS-B" for fitting the
    twinstim, then 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)."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.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).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.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.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.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).f (i.e. the length of its second argument).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).g, for instance a vector
    of time points (not just a single one).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.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.g (i.e. the length of its second argument).validpars as a way to specify parameter constraints:twinstim (with arguments
    lower and upper), and positivity constraints by using
    log-parametrizations. This component is not necessary (and ignored) if
    npars == 0.  Meyer, S. (2010):
  Spatio-Temporal Infectious Disease Epidemiology based on Point Processes.
  Master's Thesis, Ludwig-Maximilians-Universit
twinstim.# 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