File: README.md

package info (click to toggle)
r-cran-polycub 0.9.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 472 kB
  • sloc: ansic: 250; sh: 13; makefile: 2
file content (104 lines) | stat: -rw-r--r-- 3,245 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

# polyCub <img src="man/figures/logo.png" align="right" alt="" width="120" />

The [R](https://www.R-project.org/) package **polyCub** implements
*cubature* (numerical integration) over *polygonal* domains.
It solves the problem of integrating a continuously differentiable
function f(x,y) over simple closed polygons.

For the special case of a rectangular domain along the axes, the
[**cubature**](https://CRAN.R-project.org/package=cubature)
package is more appropriate (cf.
[`CRAN Task View: Numerical Mathematics`](https://CRAN.R-project.org/view=NumericalMathematics)).


## Installation

You can install
[polyCub from CRAN](https://CRAN.R-project.org/package=polyCub)
via:

```R
install.packages("polyCub")
```

To install the development version from the
[GitHub repository](https://github.com/bastistician/polyCub), use:

```R
## install.packages("remotes")
remotes::install_github("bastistician/polyCub")
```


## Usage

The basic usage is:

```r
library("polyCub")
polyCub(polyregion, f)
```

* `polyregion` represents the integration domain as an object of class
`"owin"` (from **spatstat.geom**), `"gpc.poly"` (from **gpclib**),
`"SpatialPolygons"` (from **sp**), or `"(MULTI)POLYGON"` (from **sf**),
or even as a plain list of lists of vertex coordinates (`"xylist"`).

* `f` is the integrand and needs to take a two-column coordinate matrix
as its first argument.

The `polyCub()` function wraps the implemented cubature methods and
by default calls `polyCub.SV()`, a C-implementation of *product Gauss cubature*.
Directly calling the desired cubature function is preferable,
see the list below.

### Implemented cubature methods

1. `polyCub.SV()`:
   General-purpose **product Gauss cubature**
   (Sommariva and Vianello, 2007, *BIT Numerical Mathematics*,
   <https://doi.org/10.1007/s10543-007-0131-2>)

2. `polyCub.midpoint()`:
   Simple **two-dimensional midpoint rule** based on
   [**spatstat.geom**](https://CRAN.R-project.org/package=spatstat.geom)`::as.im.function()`

3. `polyCub.iso()`:
   Adaptive **cubature for radially symmetric functions**
   via line `integrate()` along the polygon boundary
   (Meyer and Held, 2014, *The Annals of Applied Statistics*,
   <https://doi.org/10.1214/14-AOAS743>, Supplement B, Section 2.4)

<!--
4. `polyCub.exact.Gauss()`:
   Accurate (but slow) **integration of the bivariate Gaussian density**
   based on polygon triangulation and
   [**mvtnorm**](https://CRAN.R-project.org/package=mvtnorm)`::pmvnorm()`
-->

For details and illustrations see the `vignette("polyCub")`
in the installed package or
[on CRAN](https://CRAN.R-project.org/package=polyCub/vignettes/polyCub.html).


## Applications

The **polyCub** package evolved from the need to integrate
so-called spatial interaction functions (Gaussian or power-law kernels)
over the observation region of a spatio-temporal point process.
Such epidemic models are implemented in
[**surveillance**](https://CRAN.R-project.org/package=surveillance).


## Feedback

Contributions are welcome!
Please submit suggestions or report bugs at
<https://github.com/bastistician/polyCub/issues>
or via e-mail to `maintainer("polyCub")`.


## License

The **polyCub** package is free and open source software, licensed under the GPLv2.