Skip to contents

Extracts priors for specific location(s) from a priors object while maintaining the exact structure of MOSAIC::priors_default. Keeps all global parameters and filters location-specific parameters to only include the requested location(s).

Usage

get_location_priors(iso, priors = NULL)

Arguments

iso

Character vector of ISO3 country codes to extract (e.g., "ETH" or c("ETH", "KEN")).

priors

A priors list object in the format of MOSAIC::priors_default. If NULL, will use MOSAIC::priors_default.

Value

A priors list object with the same structure as the input, containing:

  • All metadata (unchanged)

  • All global parameters (unchanged)

  • Location-specific parameters filtered to only the requested location(s)

  • The reported-CFR prior block mu_jt (when present), its per-location table filtered the same way

Details

This function preserves the exact structure of the priors object:

  • metadata: Copied unchanged

  • parameters_global: All global parameters preserved

  • parameters_location: Filtered to include only the specified ISO codes

  • mu_jt: Global widths kept; per-location table filtered

The function validates that all requested locations exist in the priors before extracting. If any location is missing, an error is thrown listing the missing locations and available locations.

Examples

if (FALSE) { # \dontrun{
# Extract priors for Ethiopia
eth_priors <- get_location_priors(iso = "ETH")

# Extract priors for multiple countries
east_africa_priors <- get_location_priors(
  iso = c("ETH", "KEN", "UGA", "TZA")
)

# Use with custom priors object
my_priors <- get_location_priors(
  priors = my_custom_priors,
  iso = "SEN"
)

# Use extracted priors with sample_parameters
config_sampled <- sample_parameters(
  priors = eth_priors,
  config = my_config,
  seed = 123
)
} # }