Learn R Programming

inlabru (version 2.1.1)

sample.lgcp: Sample from an inhomogeneous Poisson process

Description

This function provides point samples from one- and two-dimensional inhomogeneous Poisson processes. The log intensity has to be provided via its values at the nodes of an inla.mesh.1d or inla.mesh object. In between mesh nodes the log intensity is assumed to be linear.

Usage

sample.lgcp(mesh, loglambda, strategy = "rectangle", R = 6371,
  samplers = NULL)

Arguments

mesh

An inla.mesh object

loglambda

A vector of log intensities at the mesh vertices (for higher order basis functions, e.g. for inla.mesh.1d meshes, loglambda should be given as mesh$m basis function weights rather than the values at the mesh$n vertices)

strategy

Only relevant for 2D meshes. Use "rectangle" for flat 2D meshes and "spherical" or "sliced-spherical" for spherical meshes.

R

Numerical value only applicable to spherical meshes. This sets the radius of the sphere approximated by the mesh. The default is 6371, which is approximately the radius of the earth in kilometers.

samplers

A SpatialPolygonsDataFrame. Simulated points that fall outside these polygons are discarded.

Value

A data.frame (1D case) or SpatialPoints (2D case) object of point locations.

Details

For 2D processes on a sphere the R parameter can be used to adjust to sphere's radius implied by the mesh. If the intensity is very high the standard strategy "spherical" can cause memory issues. Using the "sliced-spherical" strategy can help in this case.

Examples

Run this code
# NOT RUN {
library(inlabru)
vertices = seq(0, 3, by = 0.1)
mesh = inla.mesh.1d(vertices)
loglambda = 5-0.5*vertices
pts = sample.lgcp(mesh, loglambda)
pts$y = 0
plot(vertices, exp(loglambda), type = "l", ylim = c(0,150))
points(pts, pch = "|" )

data("gorillas")
pts = sample.lgcp(gorillas$mesh, rep(1.5, gorillas$mesh$n))
ggplot() + gg(gorillas$mesh) + gg(pts)
# }

Run the code above in your browser using DataLab