tune_vlmc {mixvlmc} | R Documentation |
Fit an optimal Variable Length Markov Chain (VLMC)
Description
This function fits a Variable Length Markov Chain (VLMC) to a discrete time series by optimizing an information criterion (BIC or AIC).
Usage
tune_vlmc(
x,
criterion = c("BIC", "AIC"),
initial = c("truncated", "specific", "extended"),
alpha_init = NULL,
cutoff_init = NULL,
min_size = 2L,
max_depth = 100L,
backend = getOption("mixvlmc.backend", "R"),
verbose = 0,
save = c("best", "initial", "all")
)
Arguments
x |
a discrete time series; can be numeric, character, factor and logical. |
criterion |
criterion used to select the best model. Either |
initial |
specifies the likelihood function, more precisely the way the
first few observations for which contexts cannot be calculated are
integrated in the likelihood. Default to |
alpha_init |
if non |
cutoff_init |
if non |
min_size |
integer >= 1 (default: 2). Minimum number of observations for a context in the growing phase of the initial context tree. |
max_depth |
integer >= 1 (default: 100). Longest context considered in growing phase of the initial context tree (see details). |
backend |
backend "R" or "C++" (default: as specified by the
"mixvlmc.backend" option). Specifies the implementation used to represent
the context tree and to built it. See |
verbose |
integer >= 0 (default: 0). Verbosity level of the pruning process. |
save |
specify which BIC models are saved during the pruning process.
The default value |
Details
This function automates the process of fitting a large VLMC to a discrete
time series with vlmc()
and of pruning the tree (with cutoff()
and
prune()
) to get an optimal with respect to an information criterion. To
avoid missing long term dependencies, the function uses the max_depth
parameter as an initial guess but then relies on an automatic increase of the
value to make sure the initial context tree is only limited by the min_size
parameter. The initial value of the cutoff
parameter of vlmc()
is also
set to conservative values (depending on the criterion) to avoid prior
simplification of the context tree. This default value can be overridden
using the cutoff_init
or alpha_init
parameter.
Once the initial VLMC is obtained, the cutoff()
and prune()
functions are
used to build all the VLMC models that could be generated using larger values
of the initial cut off parameter. The best model is selected from this
collection, including the initial complex tree, as the one that minimizes the
chosen information criterion.
Value
a list with the following components:
-
best_model
: the optimal VLMC -
criterion
: the criterion used to select the optimal VLMC -
initial
: the likelihood function used to select the optimal VLMC -
results
: a data frame with details about the pruning process -
saved_models
: a list of intermediate VLMCs ifsave="initial"
orsave="all"
. It contains aninitial
component with the large VLMC obtained first and anall
component with a list of all the other VLMC obtained by pruning the initial one.
See Also
Examples
dts <- sample(as.factor(c("A", "B", "C")), 100, replace = TRUE)
tune_result <- tune_vlmc(dts)
draw(tune_result$best_model)