R/c_chains_to_measure_as_list.R

Defines functions c_chains_to_measure_as_list

Documented in c_chains_to_measure_as_list

#' @rdname c_chains_to_measure_as_list
#' @title Obtain empirical measure (as list) from coupled chains
#' @description From coupled chains,
#' presumably generated via \code{\link{sample_coupled_chains}},
#' and a choice of integers k and m, the function constructs
#' a representation of an empirical signed measure, i.e.
#'
#'  \deqn{\hat{\pi}(dx) = \sum_{n=1}^N \omega_n \delta_{Z_n}(dx)}
#'
#' The function returns the weights \eqn{\omega} and the atoms \eqn{Z},
#' in a list with two entries, "weights" and "atoms".
#'
#' @param c_chains A list containing coupled chains generated by \code{\link{sample_coupled_chains}}.
#' @param k An integer at which to start computing the signed measure; should be less than m
#' @param m A time horizon: should be less than the length of the chains; typically the same
#' m that was used in the call to \code{\link{sample_coupled_chains}}, or a smaller value
#' @return A list with "weights" and "atoms"
#'@export
c_chains_to_measure_as_list <- function(c_chains, k, m){
  if (k > m){
    stop("k must be <= than m")
  }
  if (m > c_chains$iteration){
    stop("m has to be less than the time horizon of the coupled chains")
  }
  return(c_chains_to_measure_as_list_(c_chains, k, m))
}
pierrejacob/debiasedmcmc documentation built on Aug. 22, 2022, 12:41 a.m.