This function 'draws' a context tree as a text.
Usage
# S3 method for vlmc
draw(ct, control = draw_control(), prob = TRUE, ...)
# S3 method for vlmc_cpp
draw(ct, control = draw_control(), prob = TRUE, ...)
Arguments
- ct
a fitted vlmc.
- control
a list of low level control parameters of the text representation. See details and
draw_control()
.- prob
this parameter controls the display of node level information in the tree. The default
prob=TRUE
represents the conditional distribution of the states given the (partial) context associated to the node. Settingprob=FALSE
replaces the conditional distribution by the frequency of the states that follow the context as indraw.ctx_tree()
. Settingprob=NULL
removes all additional information.- ...
additional arguments for draw.
Details
The function uses basic "ascii art" to represent the context tree. Characters
used to represent the structure of the tree, e.g. branches, can be modified
using draw_control()
.
In addition to the structure of the context tree, draw
can represent
information attached to the node (contexts and partial contexts). This is
controlled by additional parameters depending on the type of the context
tree.
Examples
dts <- sample(c("A", "B", "C"), 500, replace = TRUE)
model <- vlmc(dts, alpha = 0.05)
draw(model)
#> * (0.318, 0.33, 0.352)
#> +-- B (0.3476, 0.3293, 0.3232)
#> | '-- C (0.3667, 0.2667, 0.3667)
#> | '-- C (0.4167, 0.25, 0.3333)
#> | '-- A (0.3333, 0.6667, 0)
#> '-- C (0.2955, 0.3466, 0.358)
#> +-- A (0.2712, 0.3729, 0.3559)
#> | '-- A (0.25, 0.55, 0.2)
#> | '-- C (0, 0.4286, 0.5714)
#> '-- B (0.3585, 0.283, 0.3585)
#> | '-- C (0.5909, 0.09091, 0.3182)
#> '-- C (0.2698, 0.381, 0.3492)
#> '-- B (0.2105, 0.2632, 0.5263)
#> '-- A (0, 0, 1)
draw(model, prob = FALSE)
#> * (159, 165, 176)
#> +-- B (57, 54, 53)
#> | '-- C (22, 16, 22)
#> | '-- C (10, 6, 8)
#> | '-- A (2, 4, 0)
#> '-- C (52, 61, 63)
#> +-- A (16, 22, 21)
#> | '-- A (5, 11, 4)
#> | '-- C (0, 3, 4)
#> '-- B (19, 15, 19)
#> | '-- C (13, 2, 7)
#> '-- C (17, 24, 22)
#> '-- B (4, 5, 10)
#> '-- A (0, 0, 5)
draw(model, prob = NULL)
#> *
#> +-- B
#> | '-- C
#> | '-- C
#> | '-- A
#> '-- C
#> +-- A
#> | '-- A
#> | '-- C
#> '-- B
#> | '-- C
#> '-- C
#> '-- B
#> '-- A