| multinom_TS {LDATS} | R Documentation |
Fit a multinomial change point Time Series model
Description
Fit a set of multinomial regression models (via
multinom, Venables and Ripley 2002) to a time series
of data divided into multiple segments (a.k.a. chunks) based on given
locations for a set of change points.
check_multinom_TS_inputs checks that the inputs to
multinom_TS are of proper classes for an analysis.
Usage
multinom_TS(
data,
formula,
changepoints = NULL,
timename = "time",
weights = NULL,
control = list()
)
check_multinom_TS_inputs(
data,
formula = gamma ~ 1,
changepoints = NULL,
timename = "time",
weights = NULL,
control = list()
)
Arguments
data |
|
formula |
|
changepoints |
Numeric vector indicating locations of the change
points. Must be conformable to |
timename |
|
weights |
Optional class |
control |
A |
Value
multinom_TS: Object of class multinom_TS_fit,
which is a list of [1]
chunk-level model fits ("chunk models"), [2] the total log
likelihood combined across all chunks ("logLik"), and [3] a
data.frame of chunk beginning and ending times ("logLik"
with columns "start" and "end").
check_multinom_TS_inputs: an error message is thrown if any
input is improper, otherwise NULL.
References
Venables, W. N. and B. D. Ripley. 2002. Modern and Applied Statistics with S. Fourth Edition. Springer, New York, NY, USA.
Examples
data(rodents)
dtt <- rodents$document_term_table
lda <- LDA_set(dtt, 2, 1, list(quiet = TRUE))
dct <- rodents$document_covariate_table
dct$gamma <- lda[[1]]@gamma
weights <- document_weights(dtt)
check_multinom_TS_inputs(dct, timename = "newmoon")
mts <- multinom_TS(dct, formula = gamma ~ 1, changepoints = c(20,50),
timename = "newmoon", weights = weights)