View source: R/generate_cell_draws_and_summarize.R
generate_cell_draws_and_summarize | R Documentation |
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
)
inla_model |
Output from |
inla_mesh |
An SPDE mesh used to define the spatial integration points of the INLA
geostatistical model. Typically created using |
n_samples |
(numeric) Number of posterior predictive samples to draw. |
id_raster |
(terra::SpatRaster) raster showing all cell locations where predictions should be taken. |
covariates |
(list) Named list of all covariate effects included in the model,
typically generated by |
inverse_link_function |
(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. |
nugget_in_predict |
( |
admin_boundaries |
(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. |
ui_width |
(numeric, default 0.95) Size of the uncertainty interval width when calculating the upper and lower summary rasters |
verbose |
( |
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.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.