benchmark_sampler: Benchmark posterior draws via a rejection sampler

View source: R/benchmark_sampler.R

benchmark_samplerR Documentation

Benchmark posterior draws via a rejection sampler

Description

Benchmarks draws from a posterior distribution using a rejection sampling approach. Takes in a matrix of posterior draws, and national-level benchmark data.

Usage

benchmark_sampler(
  posterior_samps,
  nregion = NA,
  ntime = 1,
  natl,
  natl_sd,
  pop_weights = NA
)

Arguments

posterior_samps

a matrix containing posterior draws at the area-level. Rows should be arranged in order arrange(region, time), with each column containing an independent draw from the posterior.

nregion

the number of regions you have estimates for. Defaults to the number of rows in posterior_samps.

ntime

the number of time points you have estimates for. Defaults to 1.

natl

a vector of national level estimates, arranged in order of time if you have multiple time points in your data.

natl_sd

a vector of standard deviations for national level estimates, arranged in order of time if you have multiple time points in your data.

pop_weights

a vector of population weights for use in the benchmarking constraint. Must sum to one at each time point, and be in order arrange(region, time)

Value

A list containing:

  • fitted_list: a list of matrices of benchmarked posterior samples of fitted values in order arrange(time). Each matrix will have rows arranged in order arrange(region).

  • natl_list: a list of vectors containing aggregated national-level samples that were accepted, in order arrange(time)

  • prop_accepted: the proportion of samples accepted during sampling.

Author(s)

Taylor Okonek


taylorokonek/stbench documentation built on Jan. 7, 2025, 11:13 p.m.