prep_ptMCMC_inputs {LDATS} | R Documentation |
Prepare the inputs for the ptMCMC algorithm estimation of change points
Description
Package the static inputs (controls and data structures) used
by the ptMCMC algorithm in the context of estimating change points.
This function was designed to work within TS
and
specifically est_changepoints
. It is still hardcoded to do
so, but has the capacity to be generalized to work with any estimation
via ptMCMC with additional coding work.
Usage
prep_ptMCMC_inputs(
data,
formula,
nchangepoints,
timename,
weights = NULL,
control = list()
)
Arguments
data |
Class |
formula |
|
nchangepoints |
Integer corresponding to the number of change points to include in the model. 0 is a valid input (corresponding to no change points, so a singular time series model), and the current implementation can reasonably include up to 6 change points. The number of change points is used to dictate the segmentation of the data for each continuous model and each LDA model. |
timename |
|
weights |
Optional class |
control |
A |
Value
Class ptMCMC_inputs
list
, containing the static
inputs for use within the ptMCMC algorithm for estimating change points.
Examples
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())