prune {mixvlmc} | R Documentation |
Prune a Variable Length Markov Chain (VLMC)
Description
This function prunes a VLMC.
Usage
prune(vlmc, alpha = 0.05, cutoff = NULL, ...)
## S3 method for class 'vlmc'
prune(vlmc, alpha = 0.05, cutoff = NULL, ...)
## S3 method for class 'vlmc_cpp'
prune(vlmc, alpha = 0.05, cutoff = NULL, ...)
Arguments
vlmc |
a fitted VLMC model. |
alpha |
number in (0,1] (default: 0.05) cut off value in quantile scale for pruning. |
cutoff |
positive number: cut off value in native (log likelihood ratio)
scale for pruning. Defaults to the value obtained from |
... |
additional arguments for the prune function. |
Details
In general, pruning a VLMC is more efficient than constructing two VLMC (the
base one and pruned one). Up to numerical instabilities, building a VLMC with
a a
cut off and then pruning it with a b
cut off (with a>b
) should
produce the same VLMC than building directly the VLMC with a b
cut off.
Interesting cut off values can be extracted from a VLMC using the cutoff()
function.
As automated model selection is provided by tune_vlmc()
, the direct use of cutoff
should be reserved to advanced exploration of the set of trees that can be
obtained from a complex one, e.g. to implement model selection techniques that
are not provided by tune_vlmc()
.
Value
a pruned VLMC
See Also
cutoff()
and tune_vlmc()
Examples
pc <- powerconsumption[powerconsumption$week == 5, ]
dts <- cut(pc$active_power, breaks = c(0, quantile(pc$active_power, probs = c(0.25, 0.5, 0.75, 1))))
base_model <- vlmc(dts, alpha = 0.1)
model_cuts <- cutoff(base_model)
pruned_model <- prune(base_model, model_cuts[3])
draw(pruned_model)
direct_simple <- vlmc(dts, alpha = model_cuts[3])
draw(direct_simple)
# pruned_model and direct_simple should be identical
all.equal(pruned_model, direct_simple)