gibbsDPP: Dirichlet Process Prior Gibbs Sampler

View source: R/gibbsDPP.R

gibbsDPPR Documentation

Dirichlet Process Prior Gibbs Sampler

Description

Auxiliary Gibbs Sampler for Dirichlet Process Prior

Usage

gibbsDPP(
  wtab,
  om,
  eta = NULL,
  etaN = NULL,
  dataToEta = NULL,
  lambda = NULL,
  lambdaN = NULL,
  dataToLambda = NULL,
  etaM = 0L,
  auxEtaM = 5L,
  alphaEta = 100,
  lambdaM = 0L,
  auxLambdaM = 5L,
  alphaLambda = 1,
  verbose = 0L,
  etaCols = 500L,
  lambdaSize = 10L,
  dprior = 1,
  lambdaShape = 1,
  lambdaRate = 0.01,
  ijvals = 0L,
  ...
)

gibbsScan(
  wtab,
  om,
  eta = NULL,
  etaN = NULL,
  dataToEta = NULL,
  etaM = 0L,
  alphaEta = 1,
  auxEtaM = 10L,
  lambda = NULL,
  lambdaN = NULL,
  dataToLambda = NULL,
  lambdaM = 0L,
  alphaLambda = 1,
  auxLambdaM = 10L,
  nkeep = 1L,
  nthin = 1L,
  nburn = 0L,
  etaCols = 50L,
  lambdaSize = 20L,
  ijvals = 0L,
  abEta = c(1e-04, 1e-04),
  abLambda = c(0.01, 0.01),
  verbose = FALSE,
  dprior = 1,
  lambdaShape = 1,
  lambdaRate = 0.01,
  keep = TRUE,
  niter.tune = 10L,
  ...
)

## S3 method for class 'ctScan'
update(object, elt = length(object), ...)

keep.default(pass, log.posterior, i, nkeep)

Arguments

wtab

the result of uniTab

om

the object returned by omega(paramList)

eta

(optional) initialization and workspace for the sampled parameters

etaN

(optional) initialization and workspace for the counts of sampled parameter vectors

dataToEta

index from the original data to the value of eta sampled

lambda

(optional) initialization and workspace for the sampled abundance parameters

lambdaN

(optional) initialization and workspace for the counts of sampled parameters

dataToLambda

index from the original data to the value of lambda sampled

etaM

number of samples provided in the intialization

auxEtaM

how many auxiliary paramters to draw

alphaEta

how much weight to place on new samples

lambdaM

how many auxiliary paramters to draw

auxLambdaM

how much space to allot for new samples. Only one new sample will be drawn if greater than zero

alphaLambda

how much weight to place on new samples

verbose

whether to report intermediate actions

etaCols

how large to make the workspace (too small a value will result in termination with an error)

lambdaSize

dprior prior value for draws of eta

dprior

symmetric Dirichlet prior value

lambdaShape

base gamma distribution prior shape

lambdaRate

base distribution prior rate

ijvals

0L by default, but for (not yet implemented) splitting and merging a value of 2 is needed. Users should not usually change the default.

...

parameters to revise using update

nkeep

the maximum number of iterations

nthin

how many iterations per saved value

nburn

discard this many iterations before saving any values

abEta

if NULL treat alphaEta as a fixed value. Otherwise the first two elements are the shape and rate parameters of Gamma prior for alphaEta.

abLambda

akin to abEta

keep

either TRUE to apply keep.default to the result in each iteration or a function called with pass, the intermediate results, and the other arguments of keep.default

niter.tune

how many cycles of tuning for each gibbs scan

object

a “ctScan” object

elt

integer to select a sample to use as the starting point

pass

a list of parameter values following an iteration, viz. the values in elements of the default return value of gibbsScan.

log.posterior

the loglikelihood evaluated at the current values of pass

i

the iteration number

Details

The auxiliary Gibbs sampler for a Dirichlet Process prior is implemented. The usual call is to gibbsScan, but update can be used to continue a chain (with no arguments) possibly changing the parameters.

gibbsDPP only does an initial Gibbs scan with no following tuning of parameters or subsequent iteration. It may be helpful for low-level access to the scanning routine, but rarely is used.

gibbsScan is the usual entry point. It conducts the Gibbs scan for eta and lambda and subseqeunt tuning alone the lines of Algorithm 8 in Neal, 2000, but the scan for lambda uses the integrated posterior from the base distribution as in Algorithm 1 of Neal, 2000 to decide whether to add a new value.

The method for update allows iterations under gibbsScan(..., keep = TRUE) to resume. If another value is used for keep some care is needed to mimic the return value as described next.

keep.default is used internally under the default (gibbsScan(..., keep = TRUE)) to return values from each iteration. Users can provide their own function to alter the collection of values from each iterate. The function should have the same number of arguments as keep.default and may pass those arguments to keep.default when i == nkeep to allow update to resume iteration.

Value

list which by default has elements eta, etaN, etaM, lambda, lambdaN, lambdaM, and dataToEta and dataToLambda which are updates to the correspondingly named inputs for gibbsDPP and a list of lists of such elements for gibbsScan. The element logLik is the loglikelihood for lambda and eta conditioning on the values of all other parameters.

Author(s)

Charles Berry

References

Radford M. Neal (2000) Markov Chain Sampling Methods for Dirichlet Process Mixture Models, Journal of Computational and Graphical Statistics, 9:2, 249-265, DOI: 10.1080/10618600.2000.10474879

Examples

tab <- diag(10, nrow = 3)[ rep(1:3,2), ] +
  rbinom(18,2,0.5)
uop <- prop.table(diag(3)+0.05,1)
gibbsScan(uniTab(tab), uop)

BushmanLab/cellTypeCompositions documentation built on June 14, 2022, 9:29 p.m.