prep_ids {LDATS} | R Documentation |
Initialize and update the chain ids throughout the ptMCMC algorithm
Description
prep_ids
creates and update_ids
updates
the active vector of identities (ids) for each of the chains in the
ptMCMC algorithm. These ids are used to track trips of the particles
among chains.
These functions were designed to work within TS
and
specifically est_changepoints
, but have been generalized
and would work within any general ptMCMC as long as control
,
ids
, and swaps
are formatted properly.
Usage
prep_ids(control = list())
update_ids(ids, swaps)
Arguments
control |
A |
ids |
The existing vector of chain ids. |
swaps |
Chain configuration after among-temperature swaps. |
Value
The vector of chain ids.
Examples
prep_ids()
data(rodents)
document_term_table <- rodents$document_term_table
document_covariate_table <- rodents$document_covariate_table
LDA_models <- LDA_set(document_term_table, topics = 2)[[1]]
data <- document_covariate_table
data$gamma <- LDA_models@gamma
weights <- document_weights(document_term_table)
data <- data[order(data[,"newmoon"]), ]
saves <- prep_saves(1, TS_control())
inputs <- prep_ptMCMC_inputs(data, gamma ~ 1, 1, "newmoon", weights,
TS_control())
cpts <- prep_cpts(data, gamma ~ 1, 1, "newmoon", weights, TS_control())
ids <- prep_ids(TS_control())
for(i in 1:TS_control()$nit){
steps <- step_chains(i, cpts, inputs)
swaps <- swap_chains(steps, inputs, ids)
saves <- update_saves(i, saves, steps, swaps)
cpts <- update_cpts(cpts, swaps)
ids <- update_ids(ids, swaps)
}
[Package LDATS version 0.3.0 Index]