sim_lgcp {stelfi} | R Documentation |
Simulate a log-Gaussian Cox process (LGCP)
Description
Simulate a realisation of a log-Gaussian Cox process (LGCP) using the
TMB
C++
template. If rho
is supplied in parameters
as well as tmesh
then spatiotemporal (AR(1)) data will be simulated.
Usage
sim_lgcp(parameters, sf, smesh, tmesh, covariates, all = FALSE)
Arguments
parameters |
A named list of parameter starting values:
Default values are used if none are provided. NOTE: these may not always be appropriate. |
sf |
An |
smesh |
A Delaunay triangulation of the spatial domain returned by |
tmesh |
Optional, a temporal mesh returned by |
covariates |
Optional, a |
all |
Logical, if |
Value
A named list. If all = FALSE
then only the simulated values of
the GMRF at each mesh node are returned, x
, alongside the number of
events, y
, simulated at each node.
See Also
Examples
if(requireNamespace("fmesher")){
if(require("sf")) {
data(xyt, package = "stelfi")
domain <- sf::st_as_sf(xyt$window)
bnd <- fmesher::fm_as_segm(as.matrix(sf::st_coordinates(domain)[, 1:2]))
smesh <- fmesher::fm_mesh_2d(boundary = bnd,
max.edge = 0.75, cutoff = 0.3)
parameters <- c(beta = 1, log_tau = log(1), log_kappa = log(1))
sim <- sim_lgcp(parameters = parameters, sf = domain, smesh = smesh)
## spatiotemporal
ndays <- 2
w0 <- 2
tmesh <- fmesher::fm_mesh_1d(seq(0, ndays, by = w0))
parameters <- c(beta = 1, log_tau = log(1), log_kappa = log(1), atanh_rho = 0.2)
sim <- sim_lgcp(parameters = parameters, sf = domain, smesh = smesh, tmesh = tmesh)
}
}