fit_lgcp {stelfi} | R Documentation |
Spatial or spatiotemporal log-Gaussian Cox process (LGCP)
Description
Fit a log-Gaussian Cox process (LGCP) using Template Model Builder (TMB) and the
R_inla
namespace for the SPDE-based construction of the latent field.
Usage
fit_lgcp(
locs,
sf,
smesh,
tmesh,
parameters,
covariates,
tmb_silent = TRUE,
nlminb_silent = TRUE,
...
)
Arguments
locs |
A |
sf |
An |
smesh |
A Delaunay triangulation of the spatial domain returned by |
tmesh |
Optional, a temporal mesh returned by |
parameters |
A named list of parameter starting values:
Default values are used if none are provided. NOTE: these may not always be appropriate. |
covariates |
Optional, a |
tmb_silent |
Logical, if |
nlminb_silent |
Logical, if |
... |
optional extra arguments to pass into |
Details
A log-Gaussian Cox process (LGCP) where the Gaussian random field, ,
has zero mean, variance-covariance matrix
, and covariance function
. The random intensity surface is
,
for design matrix
, coefficients
, and random error
.
Shown in Lindgren et. al., (2011) the stationary solution to the SPDE (stochastic
partial differential equation) is
a random field with a Matérn covariance function,
. Here
controls
the smoothness of the field and
controls the range.
A Markovian random field is obtained when is an integer. Following
Lindgren et. al., (2011) we set
in 2D and therefore fix
. Under these
conditions the solution to the SPDE is a Gaussian Markov Random Field (GMRF). This is the approximation
we use.
The (approximate) spatial range and
the standard deviation of the model,
.
Under
INLA
(Lindgren and Rue, 2015) methodology the practical range is defined as the
distance such that the correlation is .
Value
A list containing components of the fitted model, see TMB::MakeADFun
. Includes
-
par
, a numeric vector of estimated parameter values; -
objective
, the objective function; -
gr
, the TMB calculated gradient function; and -
simulate
, a simulation function.
References
Lindgren, F., Rue, H., and Lindström, J. (2011) An explicit link between Gaussian fields and Gaussian Markov random fields: the stochastic partial differential equation approach. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 73: 423–498.
Lindgren, F. and Rue, H. (2015) Bayesian spatial modelling with R-INLA. Journal of Statistical Software, 63: 1–25.
See Also
Examples
### ********************** ###
## A spatial only LGCP
### ********************** ###
if(requireNamespace("fmesher")) {
data(xyt, package = "stelfi")
domain <- sf::st_as_sf(xyt$window)
locs <- data.frame(x = xyt$x, y = xyt$y)
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)
fit <- fit_lgcp(locs = locs, sf = domain, smesh = smesh,
parameters = c(beta = 0, log_tau = log(1), log_kappa = log(1)))
### ********************** ###
## A spatiotemporal LGCP, AR(1)
### ********************** ###
ndays <- 2
locs <- data.frame(x = xyt$x, y = xyt$y, t = xyt$t)
w0 <- 2
tmesh <- fmesher::fm_mesh_1d(seq(0, ndays, by = w0))
fit <- fit_lgcp(locs = locs, sf = domain, smesh = smesh, tmesh = tmesh,
parameters = c(beta = 0, log_tau = log(1), log_kappa = log(1), atanh_rho = 0.2))
}