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:

  • beta, a vector of fixed effects coefficients to be estimated, \beta (same length as ncol(covariates) + 1 );

  • log_tau, the \textrm{log}(\tau) parameter for the GMRF;

  • log_kappa, \textrm{log}(\kappa) parameter for the GMRF;

  • atanh_rho, optional, \textrm{arctan}(\rho) AR1 temporal parameter.

Default values are used if none are provided. NOTE: these may not always be appropriate.

sf

An sf of type POLYGON specifying the spatial region of the domain.

smesh

A Delaunay triangulation of the spatial domain returned by fmesher::fm_mesh_2d().

tmesh

Optional, a temporal mesh returned by fmesher::fm_mesh_1d().

covariates

Optional, a matrix of covariates at each smesh and tmesh node combination.

all

Logical, if TRUE then all model components are returned.

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

fit_lgcp

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)
}
}

[Package stelfi version 1.0.1 Index]