Use INLA posteriors to predict out across a grid
generate_cell_draws_and_summarize(
inla_model,
inla_mesh,
n_samples,
id_raster,
covariates,
inverse_link_function,
nugget_in_predict = TRUE,
admin_boundaries = NULL,
ui_width = 0.95,
verbose = TRUE
)Named list containing at least the following items:
"parameter_draws": posterior samples generated from INLA::inla.posterior.sample()
"cell_draws": A matrix of grid cell draws. Each row represents a non-NA pixel in
the id_raster, in the same order that would be pulled by terra::values(), and
each column represents a different posterior draw.
"cell_pred_mean": Mean predictive estimate by grid cell, formatted as a terra SpatRaster
"cell_pred_lower": Lower bound of (X%) uncertainty interval, formatted as a terra SpatRaster
"cell_pred_upper": Upper bound of (X%) uncertainty interval, formatted as a terra SpatRaster
Output from fit_inla_model()
An SPDE mesh used to define the spatial integration points of the INLA
geostatistical model. Typically created using INLA::inla.mesh.2d() or a similar
function.
(numeric) Number of posterior predictive samples to draw.
(terra::SpatRaster) raster showing all cell locations where predictions should be taken.
(list) Named list of all covariate effects included in the model,
typically generated by load_covariates().
(character) If a link function was used in the INLA model, name of the R function to transform the predictive draws from link space to natural space. For example, in a logit-linked binomial model, pass 'plogis' (as a string is fine) to invert-logit the predictive draws.
(logical(1), default TRUE) Should the nugget term be used as
an IID noise term applied to each pixel-draw?
(sf object, default NULL) The same admin boundaries used to create the admin-level effect, if one was defined in the model. Only used if an admin-level effect was defined in the model.
(numeric, default 0.95) Size of the uncertainty interval width when calculating the upper and lower summary rasters
(logical(1), default TRUE) Log progress for draw generation?
Based on a fitted INLA model, the survey area defined in an ID raster, and a set of covariates, generate predictive grid cell draws and summary rasters across a study area.