Computes predictive targets over polygon features using joint prediction
samples from pred_over_grid. Targets can incorporate
covariates, offsets, optional unstructured random effects, and (if fitted)
mass drug administration (MDA) effects from a DAST model.
pred_target_shp(
object,
shp,
shp_target = mean,
weights = NULL,
standardize_weights = FALSE,
col_names = NULL,
include_covariates = TRUE,
include_nugget = FALSE,
include_cov_offset = FALSE,
include_mda_effect = TRUE,
return_shp = TRUE,
time_pred = NULL,
mda_grid = NULL,
include_re = FALSE,
f_target = NULL,
pd_summary = NULL,
messages = TRUE,
return_target_samples = FALSE
)An object of class RiskMap_pred_target_shp with components:
target: data.frame of region-level summaries (one row per region).
target_samples: (optional) list with one element per region; each contains
a data.frame/matrix of raw samples for each named target in f_target,
if return_target_samples = TRUE.
shp: (optional) the input sf object with appended summary columns,
included if return_shp = TRUE.
f_target, pd_summary, grid_pred: inputs echoed for reproducibility.
Output from pred_over_grid (class RiskMap.pred.re),
typically fitted with type = "joint" so that linear predictor samples are available.
An sf polygon object (preferred) or a data.frame with an
attached geometry column, representing regions over which predictions are aggregated.
A function that aggregates grid-cell values within each polygon to a
single regional value (default mean). Examples: mean, sum,
a custom weighted mean, etc.
Optional numeric vector of weights used inside shp_target.
If supplied with standardize_weights = TRUE, weights are normalized within each region.
Logical; standardize weights within each region (FALSE by default).
Name or column index in shp containing region identifiers to use in outputs.
Logical; include fitted covariate effects in the linear predictor (default TRUE).
Logical; include the nugget (unstructured measurement error) in the linear predictor (default FALSE).
Logical; include any covariate offset term (default FALSE).
Logical; include the MDA effect as defined by the fitted DAST model
(default TRUE). Requires time_pred and, when applicable, mda_grid.
Logical; if TRUE, return the shapefile with appended summary columns
defined by pd_summary (default TRUE).
Optional numeric scalar (or time index) at which to evaluate the predictive target
Optional structure describing MDA schedules aligned with prediction grid cells
(e.g., a data.frame/matrix/list). Used only when include_mda_effect = TRUE.
Logical; include unstructured random effects (RE) in the linear predictor (default FALSE).
List of target functions applied to linear predictor samples (e.g.,
list(prev = plogis) for prevalence on the probability scale). If NULL,
the identity is used.
Named list of summary functions applied to each region's target samples
(e.g., list(mean = mean, sd = sd, q025 = function(x) quantile(x, 0.025), q975 = function(x) quantile(x, 0.975))).
Names are used as column suffixes in the outputs.
Logical; if TRUE, print progress messages while computing regional targets.
Logical; if TRUE, also return the raw target samples per region
(default FALSE).
For each polygon in shp, grid-cell samples of the linear predictor are transformed with
f_target, optionally adjusted for covariates, offset, nugget, MDA effects and/or REs, and
then aggregated via shp_target (optionally weighted). The list pd_summary is applied
to each region's target samples to produce summary statistics.
pred_over_grid, pred_target_grid