R/as-mcmc.R

Defines functions as.mcmc.mcmcr as.mcmc.mcmc as.mcmc.mcmcarray as.mcmc.mcarray as.mcmc.nlists

Documented in as.mcmc.mcarray as.mcmc.mcmc as.mcmc.mcmcarray as.mcmc.mcmcr

#' @export
coda::as.mcmc

as.mcmc.nlists <- function(x, ...) {
  as.mcmc(as.mcmcr(x))
}

#' @inherit coda::as.mcmc
#' @export
as.mcmc.mcarray <- function(x, ...) as.mcmc(as.mcmcarray(x))

#' @inherit coda::as.mcmc
#' @export
as.mcmc.mcmcarray <- function(x, ...) {
  chk_identical(nchains(x), 1L)
  term <- as_term(x)
  x <- apply(x, 1, identity)
  x <- matrix(x, ncol = length(term))
  colnames(x) <- as.character(term)
  as.mcmc(x)
}

#' @inherit coda::as.mcmc
#' @export
as.mcmc.mcmc <- function(x, ...) x

#' @inherit coda::as.mcmc
#' @export
as.mcmc.mcmcr <- function(x, ...) as.mcmc(as.mcmc.list(x))

Try the mcmcr package in your browser

Any scripts or data that you put into this service are public.

mcmcr documentation built on Sept. 7, 2021, 1:07 a.m.