polyCub.iso | R Documentation |
polyCub.iso
numerically integrates a radially symmetric function
f(x,y) = f_r(||(x,y)-\boldsymbol{\mu}||)
,
with \mu
being the center of isotropy, over a polygonal domain.
It internally approximates a line integral along the polygon boundary using
integrate
. The integrand requires the antiderivative of
r f_r(r)
), which should be supplied as argument intrfr
(f
itself is only required if check.intrfr=TRUE
).
The two-dimensional integration problem thereby reduces to an efficient
adaptive quadrature in one dimension.
If intrfr
is not available analytically, polyCub.iso
can use a
numerical approximation (meaning integrate
within integrate
),
but the general-purpose cubature method polyCub.SV
might be
more efficient in this case.
See Meyer and Held (2014, Supplement B, Section 2.4) for mathematical
details.
.polyCub.iso
is a “bare-bone” version of polyCub.iso
.
polyCub.iso(polyregion, f, intrfr, ..., center, control = list(),
check.intrfr = FALSE, plot = FALSE)
.polyCub.iso(polys, intrfr, ..., center, control = list(),
.witherror = FALSE)
polyregion |
a polygonal domain.
The following classes are supported:
|
f |
a two-dimensional real-valued function. As its first argument it must take a coordinate matrix, i.e., a numeric matrix with two columns, and it must return a numeric vector of length the number of coordinates. |
intrfr |
a |
... |
further arguments for |
center |
numeric vector of length 2, the center of isotropy. |
control |
list of arguments passed to |
check.intrfr |
logical (or numeric vector) indicating if
(for which |
plot |
logical indicating if an image of the function should be plotted
together with the polygonal domain, i.e.,
|
polys |
something like |
.witherror |
logical indicating if an upper bound for the absolute integration error should be attached as an attribute to the result? |
The approximate integral of the isotropic function
f
over polyregion
.
If the intrfr
function is provided (which is assumed to be exact), an
upper bound for the absolute integration error is appended to the result as
attribute "abs.error"
. It equals the sum of the absolute errors
reported by all integrate
calls
(there is one for each edge of polyregion
).
Sebastian Meyer
The basic mathematical formulation of this efficient integration for radially symmetric functions was ascertained with great support by Emil Hedevang (2013), Dept. of Mathematics, Aarhus University, Denmark.
Hedevang, E. (2013). Personal communication at the Summer School on Topics in Space-Time Modeling and Inference (May 2013, Aalborg, Denmark).
Meyer, S. and Held, L. (2014). Power-law models for infectious disease spread. The Annals of Applied Statistics, 8 (3), 1612-1639. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1214/14-AOAS743")}
system.file("include", "polyCubAPI.h", package = "polyCub")
for a full C-implementation of this cubature method (for a single
polygon). The corresponding C-routine polyCub_iso
can be used by
other R packages, notably surveillance, via ‘LinkingTo: polyCub’
(in the ‘DESCRIPTION’) and ‘#include <polyCubAPI.h>’ (in suitable
‘/src’ files). Note that the intrfr
function must then also be
supplied as a C-routine. An example can be found in the package tests.
Other polyCub-methods:
polyCub()
,
polyCub.SV()
,
polyCub.exact.Gauss()
,
polyCub.midpoint()
## we use the example polygon and f (exponential decay) from
example(plotpolyf)
## numerical approximation of 'intrfr' (not recommended)
(intISOnum <- polyCub.iso(letterR, f, center = fcenter))
## analytical 'intrfr'
## intrfr(R) = int_0^R r*f(r) dr, for f(r) = dexp(r), gives
intrfr <- function (R, rate = 1) pgamma(R, 2, rate) / rate
(intISOana <- polyCub.iso(letterR, f, intrfr = intrfr, center = fcenter,
check.intrfr = TRUE))
## f is only used to check 'intrfr' against a numerical approximation
stopifnot(all.equal(intISOana, intISOnum, check.attributes = FALSE))
### polygon area: f(r) = 1, f(x,y) = 1, center does not really matter
## intrfr(R) = int_0^R r*f(r) dr = int_0^R r dr = R^2/2
intrfr.const <- function (R) R^2/2
(area.ISO <- polyCub.iso(letterR, intrfr = intrfr.const, center = c(0,0)))
if (require("spatstat.geom")) { # check against area.owin()
stopifnot(all.equal(area.owin(owin(poly = letterR)),
area.ISO, check.attributes = FALSE))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.