prep_cpts | R Documentation |
Each of the chains is initialized by prep_cpts
using a
draw from the available times (i.e. assuming a uniform prior), the best
fit (by likelihood) draw is put in the focal chain with each subsequently
worse fit placed into the subsequently hotter chain. update_cpts
updates the change points after every iteration in the ptMCMC algorithm.
prep_cpts(data, formula, nchangepoints, timename, weights, control = list())
update_cpts(cpts, swaps)
data |
|
formula |
|
nchangepoints |
|
timename |
|
weights |
Optional class |
control |
A |
cpts |
The existing matrix of change points. |
swaps |
Chain configuration after among-temperature swaps. |
list
of [1] matrix
of change points (rows) for
each temperature (columns) and [2] vector
of log-likelihood
values for each of the chains.
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.