Busabase
Busabase는 AI 에이전트를 위한 오픈소스(MIT) 데이터베이스 및 작업 공간입니다
MCMC 샘플을 저장·조작·요약하는 함수와 클래스 제공
Functions and classes to store, manipulate and summarise Monte Carlo Markov Chain (MCMC) samples. For more information see Brooks et al. (2011) <isbn:978-1-4200-7941-8>.
데이터HTML · RGitHub @poissonconsulting온라인운영자 미확인
써 보셨어요? 한 번만 눌러 주세요. 로그인은 필요 없어요.
An R package to manipulate MCMC samples
README 전체를 불러오는 중입니다.
README 전문 보기 ↗mcmcr is an R package to manipulate Monte Carlo Markov Chain (MCMC)
samples.
For the purposes of this discussion, an MCMC sample represents the value of a term from a single iteration of a single chain. While a simple parameter such as an intercept corresponds to a single term, more complex parameters such as an interaction between two factors consists of multiple terms with their own inherent dimensionality - in this case a matrix. A set of MCMC samples can be stored in different ways.
The three most common S3 classes store MCMC samples as follows:
coda::mcmc stores the MCMC samples from a single chain as a matrix
where each each row represents an iteration and each column represents
a variablecoda::mcmc.list stores multiple mcmc objects (with identical
dimensions) as a list where each object represents a parallel chainrjags::mcarray stores the samples from a single parameter where the
initial dimensions are the parameter dimensions, the second to last
dimension is iterations and the last dimension is chains.In the first two cases the terms/parameters are represented by a single
dimension which means that the dimensionality inherent in the parameters
is stored in the labelling of the variables, ie,
"bIntercept", "bInteraction[1,2]", "bInteraction[2,1]", .... The
structure of the mcmc and mcmc.list objects emphasizes the
time-series nature of MCMC samples and is optimized for thining. In
contrast mcarray objects preserve the dimensionality of the
parameters.
The mcmcr package defines three related S3 classes which also preserve
the dimensionality of the parameters:
mcmcr::mcmcarray is very similar to rjags::mcarray except that the
first dimension is the chains, the second dimension is iterations and
the subsequent dimensions represent the dimensionality of the
parameter (it is called mcmcarray to emphasize that the MCMC
dimensions ie the chains and iterations come first);mcmcr::mcmcr stores multiple uniquely named mcmcarray objects with
the same number of chains and iterations.mcmcr::mcmcrs stores multiple mcmcr objects with the same
parameters, chains and iterations.All five classes (mcmc, mcmc.list, mcarray, mcmcarray, mcmcr
and mcmcrs) are collectively referred to as MCMC objects.
mcmcarray objects were developed to facilitate manipulation of the
MCMC samples. mcmcr objects were developed to allow a set of
dimensionality preserving parameters from a single analysis to be
manipulated as a whole. mcmcrs objects were developed to allow the
results of multiple analyses using the same model to be manipulated
together.
The mcmcr package (together with the
term and
nlist packages) introduces
a variety of (often) generic functions to manipulate and query
mcmcarray, mcmcr and mcmcrs objects (and term and nlist and
nlists objects).
In particular it provides functions to
mcarray, mcmc and mcmc.list objects;coef table (as a tibble);nchains, niters, term::npars, term::nterms,
nlist::nsims and nlist::nsams as well as it’s parameter dimensions
(term::pdims) and term indices (term::tindex);subset objects by chains, iterations and/or parameters;bind_xx a pair of objects by their xx_chains, xx_iterations,
xx_parameters or (parameter) xx_dimensions;combine_samples (or combine_samples_n) or combine the samples of a
single MCMC object by reducing its dimensions using
combine_dimensions;collapse_chains or split_chains an object’s chains;mcmc_map over an objects values;mcmc_aperm;converged using rhat and esr
(effectively sampling rate);thin, rhat, ess (effective sample size), print,
plot etc said objects.The code is opinionated which has the advantage of providing a small set
of stream-lined functions. For example the only ‘convergence’ metric is
the uncorrected, untransformed, univariate split R-hat (potential scale
reduction factor). If you can convince me that additional features are
important I will add them or accept a pull request (see below).
Alternatively you might want to use the mcmcr package to manipulate
your samples before coercing them to an mcmc.list to take advantage of
all the summary functions in packages such as coda.
여기까지가 README 앞부분입니다. 나머지는 원문에서 읽을 수 있습니다. README 전문 보기 ↗