Skip to contents

This function returns a collection of cut off values that are guaranteed to induce all valid pruned trees of the context tree of a VLMC. Pruning is implemented by the prune() function.

Usage

# S3 method for vlmc
cutoff(
  model,
  scale = c("quantile", "native"),
  raw = FALSE,
  tolerance = .Machine$double.eps^0.5,
  ...
)

# S3 method for vlmc_cpp
cutoff(
  model,
  scale = c("quantile", "native"),
  raw = FALSE,
  tolerance = .Machine$double.eps^0.5,
  ...
)

Arguments

model

a fitted VLMC model.

scale

specify whether the results should be "native" log likelihood ratio values or expressed in a "quantile" scale of a chi-squared distribution (defaults to "quantile").

raw

specify whether the returned values should be limit values computed in the model or modified values that guarantee pruning (see details)

tolerance

specify the minimum separation between two consecutive values of the cut off in native mode (before any transformation). See details.

...

additional arguments for the cutoff function.

Value

a vector of cut off values.

Details

By default, the function returns values that can be used directly to induce pruning in the context tree. This is done by computing the log likelihood ratios used by the context algorithm on the reference VLMC and by keeping the relevant ones. From them the function selects intermediate values that are guaranteed to generate via pruning all the VLMC models that could be generated by using larger values of the cutoff parameter that was used to build the reference model (or smaller values of the alpha parameter in "quantile" scale).

Setting the raw parameter to TRUE removes this operation on the values and asks the function to return the relevant log likelihood ratios.

For large VLMC, some log likelihood ratios can be almost identical, with a difference of the order of the machine epsilon value. The tolerance parameter is used to keep only values that are different enough. This is done in the native scale, before transformations implemented when raw is FALSE.

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().

See also

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))))
model <- vlmc(dts)
draw(model)
#> * (0.25, 0.25, 0.25, 0.25)
#> +-- (0,0.458] (0.7968, 0.1912, 0.007968, 0.003984)
#> |   '-- (0,0.458] (0.809, 0.1809, 0.005025, 0.005025)
#> |       '-- (0,0.458] (0.8188, 0.1688, 0.00625, 0.00625)
#> |           '-- (0,0.458] (0.8462, 0.1385, 0.007692, 0.007692)
#> |               '-- (0.458,1.34] (0.55, 0.4, 0, 0.05)
#> '-- (0.458,1.34] (0.1984, 0.6667, 0.1071, 0.02778)
#> |   +-- (0,0.458] (0.375, 0.4167, 0.1458, 0.0625)
#> |   |   '-- (0,0.458] (0.3611, 0.4444, 0.1389, 0.05556)
#> |   |       '-- (0.458,1.34] (0, 0.8889, 0.1111, 0)
#> |   '-- (0.458,1.34] (0.1369, 0.75, 0.09524, 0.01786)
#> |       '-- (0,0.458] (0.4, 0.55, 0.05, 0)
#> '-- (1.34,2.13] (0.003968, 0.123, 0.7262, 0.1468)
#> |   '-- (2.13,7.54] (0, 0.2, 0.525, 0.275)
#> '-- (2.13,7.54] (0.003968, 0.01587, 0.1587, 0.8214)
#>     '-- (0.458,1.34] (0, 0.1429, 0.5714, 0.2857)
model_cuts <- cutoff(model)
model_2 <- prune(model, model_cuts[2])
draw(model_2)
#> * (0.25, 0.25, 0.25, 0.25)
#> +-- (0,0.458] (0.7968, 0.1912, 0.007968, 0.003984)
#> |   '-- (0,0.458] (0.809, 0.1809, 0.005025, 0.005025)
#> |       '-- (0,0.458] (0.8188, 0.1688, 0.00625, 0.00625)
#> |           '-- (0,0.458] (0.8462, 0.1385, 0.007692, 0.007692)
#> |               '-- (0.458,1.34] (0.55, 0.4, 0, 0.05)
#> '-- (0.458,1.34] (0.1984, 0.6667, 0.1071, 0.02778)
#> |   '-- (0,0.458] (0.375, 0.4167, 0.1458, 0.0625)
#> |       '-- (0,0.458] (0.3611, 0.4444, 0.1389, 0.05556)
#> |           '-- (0.458,1.34] (0, 0.8889, 0.1111, 0)
#> '-- (1.34,2.13] (0.003968, 0.123, 0.7262, 0.1468)
#> '-- (2.13,7.54] (0.003968, 0.01587, 0.1587, 0.8214)
#>     '-- (0.458,1.34] (0, 0.1429, 0.5714, 0.2857)