benchmark_mh: Benchmark posterior draws via a Metropolis-Hastings algorithm

View source: R/benchmark_mh.R

benchmark_mhR Documentation

Benchmark posterior draws via a Metropolis-Hastings algorithm

Description

Benchmarks draws from a posterior distribution using a Metropolis-Hastings approach. Takes in a matrix of posterior draws, a matrix of fixed effect draws, and national-level benchmark data.

Usage

benchmark_mh(
  posterior_samps,
  posterior_samps_fe,
  nregion = NA,
  ntime = 1,
  natl,
  natl_sd,
  pop_weights = NA,
  fe_prior_means,
  fe_prior_variances
)

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.

posterior_samps_fe

a matrix containing posterior draws of fixed effects (typically intercepts) that have had prior means and variances shifted in the unbenchmarked model, 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)

fe_prior_means

a vector of prior means for the fixed effects specified in posterior_samps_fe. Must be in row order of posterior_samps_fe.

fe_prior_variances

a vector of prior variances for the fixed effects specified in posterior_samps_fe Must be in row order of posterior_samps_fe.

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.