draw.covlmc {mixvlmc}R Documentation

Text based representation of a covlmc model

Description

This function 'draws' a context tree as a text.

Usage

## S3 method for class 'covlmc'
draw(
  ct,
  control = draw_control(),
  model = c("coef", "full"),
  p_value = TRUE,
  digits = 4,
  with_state = FALSE,
  ...
)

Arguments

ct

a fitted covlmc model.

control

a list of low level control parameters of the text representation. See details and draw_control().

model

this parameter controls the display of logistic models associated to nodes. The default model="coef" represents the coefficients of the logistic models associated to each context. model="full" includes the name of the variables in the representation (see details). Setting model=NULL removes the model representations. Additional parameters can be used to tweak model representations (see details).

p_value

specifies whether the p-values of the likelihood ratio tests conducted during the covlmc construction must be included in the representation.

digits

numerical parameters and p-values are represented using the base::signif function, using the number of significant digits specified with this parameter.

with_state

specifies whether to display the state associated to each dimension of the logistic model (see details).

...

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.

Value

the context tree (invisibly).

Tweaking model representation

Model representations are affected by the following additional parameter:

Variable representation

When model="full", the representation includes the names of the variables used by the logistic models. Names are the one generated by the underlying logistic model, e.g. stats::glm(). Numerical variable names are used as is, while factors have levels appended. The intercept is denoted (I) to save space. The time delays are represented by an underscore followed by the time delay. For instance if the model uses the numerical covariate y with two delays, it will appear as to variables y_1 and y_2.

State representation

When model is not NULL, the coefficients of the logistic models are presented, organized in rows associated to states. One state is used as the reference state and the logistic model aims at predicting the ratio of probability between another state and the reference one (in log scale). When with_state is TRUE, the display includes for each row of coefficients the target state. This is useful when using e.g. VGAM::vglm as unused levels of the target variable will be automatically dropped from the model, leading to a reduce number of rows. The reference state is either shown on the first row if model is "full" or after the state on each row if model is "coef".

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 = 5)
draw(m_cov, digits = 3)
draw(m_cov, model = NULL)
draw(m_cov, p_value = FALSE)
draw(m_cov, p_value = FALSE, time_sep = " | ")
draw(m_cov, model = "full", time_sep = " | ")

[Package mixvlmc version 0.2.1 Index]