Prepare data stack for INLA
prepare_inla_data_stack(
input_data,
id_raster,
covariates,
use_covariates = TRUE,
covariates_sum_to_one = FALSE,
family = "binomial",
use_spde = TRUE,
spde_range_pc_prior = list(threshold = 0.1, prob_below = 0.05),
spde_sigma_pc_prior = list(threshold = 3, prob_above = 0.05),
spde_integrate_to_zero = TRUE,
mesh_max_edge = c(0.2, 5),
mesh_cutoff = 0.04,
use_nugget = TRUE,
nugget_pc_prior = list(threshold = 3, prob_above = 0.05),
use_admin_effect = FALSE,
admin_boundaries = NULL,
admin_pc_prior = list(threshold = 3, prob_above = 0.05)
)
List containing the following items:
"mesh": The mesh used to approximate the latent Gaussian process
"spde": The SPDE object that will be used to fit the INLA model
"inla_data_stack": The data stack to be passed to INLA::inla()
"formula_string": The formula specification to be passed to INLA::inla()
A data.frame with at least the following columns:
'indicator': number of "hits' per site, e.g. tested positive for malaria
'samplesize': total population sampled at the site
'x': x position, often longitude
'y': y position, often latitude
terra::SpatRaster with non-NA pixels delineating the extent of the study area
(list) Named list of all covariate effects included in the model,
typically generated by load_covariates()
. Only used if use_covariates
is TRUE.
(boolean(1)
, default TRUE) Should covariate fixed effects be
included in the model? If TRUE, includes fixed effects for all covariates in the
covariates
argument. If FALSE, includes only an intercept.
(logical, default FALSE) Should the input covariates be constrained to sum to one? Usually FALSE when raw covariates are passed to the model, and TRUE if running an ensemble (stacking) model.
(character(1)
, default 'binomial') Statistical family; used to
link stacked covariates with outcomes
(boolean(1)
, default TRUE) Should an SPDE approximation of a Gaussian
process be included in the model?
(list) A named list specifying the penalized complexity prior for the SPDE range. The two named items are "threshold", the test threshold (set as a proportion of the overall mesh extent), and "prob_below", the prior probability that the value is BELOW that range threshold. The function automatically converts "threshold" from a proportion of the overall mesh extent into a distance.
(list) A named list specifying the penalized complexity prior for sigma (standard deviation) of the SPDE object. The two named items are "threshold", the test threshold for the standard deviation, and "prob_above", the prior probability that sigma will EXCEED that threshold.
(boolean(1)
, default TRUE) Should the 'volume' under
the SPDE mesh integrate to zero?
(numeric(2)
, default c(0.2, 5)) Maximum size of the INLA SPDE
mesh inside (1) and outside (2) of the modeled region.
(numeric(1)
, default 0.04) Minimum size of the INLA mesh, usually
reached in data-dense areas.
(boolean(1)
, default TRUE) Should a nugget (IID observation-level
error or noise) term be included?
A named list specifying the penalized complexity prior for the
nugget term. The two named items are "threshold", the test threshold for the nugget
standard deviation, and "prob_above", the prior probability that the standard
deviation will EXCEED that threshold. Only used if use_nugget
is TRUE
(boolean(1)
, default FALSE) Should an IID random effect by
administrative unit be included?
(sf object, default NULL) admin boundaries spatial
object. Only used if use_admin_effect
is TRUE
(list) A named list specifying the penalized complexity prior
for the admin-level IID term. The two named items are "threshold", the test threshold
for the standard deviation of admin-level effects, and "prob_above", the prior
probability that the standard deviation will EXCEED that threshold. Only used if
use_admin_effect
is TRUE.
Creates the formatted input data to be used by the INLA model. For more information about penalized complexity priors, see Daniel Simpson's paper on the subject: tools:::Rd_expr_doi("doi:10.1214/16-STS576")
fit_inla_model()
MbgModelRunner