Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

twinstim_siaf_simulatePC

Simulation from an Isotropic Spatial Kernel via Polar Coordinates


Description

To sample points from isotropic spatial kernels f_2(s) = f(||s||) such as siaf.powerlaw on a bounded domain (i.e., ||s|| < \code{ub}), it is convenient to switch to polar coordinates (r,θ), which have a density proportional to r f_2((r \cos(θ), r \sin(θ))) = r f(r) (independent of the angle θ due to isotropy). The angle is thus simply drawn uniformly in [0,2π), and r can be sampled by the inversion method, where numeric root finding is used for the quantiles (since the quantile function is not available in closed form).

Usage

siaf.simulatePC(intrfr)

Arguments

intrfr

a function computing the integral of r f(r) from 0 to R (first argument, not necessarily named R). Parameters of the function are passed as its second argument and a third argument is the event type.

Value

a function with arguments (n, siafpars, type, ub), which samples n points from the spatial kernel f_2(s) within the disc of radius ub, where siafpars and type are passed as second and third argument to intrfr. The environment of the returned function will be the caller's environment.

Author(s)

Sebastian Meyer

Examples

simfun <- siaf.powerlaw()$simulate
## is internally generated as siaf.simulatePC(intrfr.powerlaw)

set.seed(1)
simfun(n=10, siafpars=log(c(sigma=1, d=2)), ub=5)

surveillance

Temporal and Spatio-Temporal Modeling and Monitoring of Epidemic Phenomena

v1.19.1
GPL-2
Authors
Michael H<f6>hle [aut, ths] (<https://orcid.org/0000-0002-0423-6702>), Sebastian Meyer [aut, cre] (<https://orcid.org/0000-0002-1791-9449>), Michaela Paul [aut], Leonhard Held [ctb, ths], Howard Burkom [ctb], Thais Correa [ctb], Mathias Hofmann [ctb], Christian Lang [ctb], Juliane Manitz [ctb], Andrea Riebler [ctb], Daniel Saban<e9>s Bov<e9> [ctb], Ma<eb>lle Salmon [ctb], Dirk Schumacher [ctb], Stefan Steiner [ctb], Mikko Virtanen [ctb], Wei Wei [ctb], Valentin Wimmer [ctb], R Core Team [ctb] (A few code segments are modified versions of code from base R)
Initial release
2021-03-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.