find_sequence.covlmc {mixvlmc}R Documentation

Find the node of a sequence in a COVLMC context tree

Description

This function checks whether the sequence ctx is represented in the context tree of the COVLMC model ct. If this is the case, it returns a description of matching node, an object of class ctx_node_covlmc. If the sequence is not represented in the tree, the function return NULL.

Usage

## S3 method for class 'covlmc'
find_sequence(ct, ctx, reverse = FALSE, ...)

Arguments

ct

a context tree.

ctx

a sequence to search in the context tree

reverse

specifies whether the sequence ctx is given the temporal order (FALSE, default value) or in the reverse temporal order (TRUE). See the dedicated section.

...

additional parameters for the find_sequence function

Details

The function looks for sequences in general. The is_context() function can be used on the resulting object to test if the sequence is in addition a proper context.

Value

an object of class ctx_node_covlmc if the sequence ctx is represented in the context tree, NULL when this is not the case

State order in a sequence

sequence are given by default in the temporal order and not in the "reverse" order used by many VLMC research papers: older values are on the left. For instance, the context c(1, 0) is reported if the sequence 0, then 1 appeared in the time series used to build the context tree. In the present function, reverse refers both to the order used for the ctx parameter and for the default order used by the resulting ctx_node object.

Examples

pc <- powerconsumption[powerconsumption$week == 5, ]
dts <- cut(pc$active_power, breaks = c(0, quantile(pc$active_power, probs = c(0.5, 1))))
dts_cov <- data.frame(day_night = (pc$hour >= 7 & pc$hour <= 17))
m_cov <- covlmc(dts, dts_cov, min_size = 10)

## not in the tree
vals <- states(m_cov)
find_sequence(m_cov, c(vals[2], vals[2]))
## in the tree but not a context
node <- find_sequence(m_cov, c(vals[1]))
node
is_context(node)
## in the tree and a context
node <- find_sequence(m_cov, c(vals[1], vals[1]))
node
is_context(node)
model(node)

[Package mixvlmc version 0.2.1 Index]