ctx_tree {mixvlmc}R Documentation

Build a context tree for a discrete time series

Description

This function builds a context tree for a time series.

Usage

ctx_tree(
  x,
  min_size = 2L,
  max_depth = 100L,
  keep_position = TRUE,
  backend = getOption("mixvlmc.backend", "R")
)

Arguments

x

a discrete time series; can be numeric, character, factor or logical.

min_size

integer >= 1 (default: 2). Minimum number of observations for a context to be included in the tree.

max_depth

integer >= 1 (default: 100). Maximum length of a context to be included in the tree.

keep_position

logical (default: TRUE). Should the context tree keep the position of the contexts.

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 details.

Details

The tree represents all the sequences of symbols/states of length smaller than max_depth that appear at least min_size times in the time series and stores the frequencies of the states that follow each context. Optionally, the positions of the contexts in the time series can be stored in the tree.

Value

a context tree (of class that inherits from ctx_tree).

Back ends

Two back ends are available to compute context trees:

Examples

dts <- c(0, 1, 1, 1, 0, 0, 1, 0, 1, 0)
## get all contexts of length 2
dts_ctree <- ctx_tree(dts, min_size = 1, max_depth = 2)
draw(dts_ctree)

[Package mixvlmc version 0.2.1 Index]