nmfkc.ar.DOT: Generate a Graphviz DOT Diagram for NMF-AR / NMF-VAR Models

View source: R/nmfkc.ar.R

nmfkc.ar.DOTR Documentation

Generate a Graphviz DOT Diagram for NMF-AR / NMF-VAR Models

Description

Produces a Graphviz DOT script for visualizing autoregressive NMF-with-covariates models constructed via nmfkc.ar + nmfkc.

The diagram displays three types of directed relationships:

  • Lagged predictors: T_{t-k} \rightarrow X,

  • Current latent factors: X \rightarrow T_t,

  • Optional intercept effects: Const -> X.

Importantly, no direct edges from lagged variables to current outputs (T_{t-k} \rightarrow T_t) are drawn, in accordance with the NMF-AR formulation.

Each block of lagged variables is displayed in its own DOT subgraph (e.g., “T-1”, “T-2”, ...), while latent factor nodes and current-time outputs are arranged in separate clusters.

Usage

nmfkc.ar.DOT(
  result,
  degree = 1,
  intercept = any(colnames(result$C) == "(Intercept)"),
  threshold = 0.1,
  rankdir = "RL",
  fill = TRUE,
  weight_scale_xy = 5,
  weight_scale_lag = 5,
  weight_scale_int = 3,
  hide.isolated = TRUE
)

Arguments

result

A fitted nmfkc object representing the AR model. Must contain matrices X and C.

degree

Maximum AR lag to visualize.

intercept

Logical; if TRUE, draws intercept nodes for columns named "(Intercept)" in matrix C. Default is TRUE when an intercept column is detected in C, FALSE otherwise (auto-detected).

threshold

Minimum coefficient magnitude required to draw an edge.

rankdir

Graphviz rank direction (e.g., "RL", "LR", "TB").

fill

Logical; whether nodes are filled with color.

weight_scale_xy

Scaling factor for edges X \rightarrow T.

weight_scale_lag

Scaling factor for lagged edges T-k \rightarrow X.

weight_scale_int

Scaling factor for intercept edges.

hide.isolated

Logical. If TRUE (default), Y nodes that have no edges at or above threshold are excluded from the graph.

Value

A character string representing a Graphviz DOT file.

See Also

nmfkc.ar, nmfkc, plot.nmfkc.DOT

Examples

d <- AirPassengers
ar_data <- nmfkc.ar(d, degree = 2)
result <- nmfkc(ar_data$Y, ar_data$A, rank = 1)
dot <- nmfkc.ar.DOT(result, degree = 2)
cat(dot)


nmfkc documentation built on July 14, 2026, 1:07 a.m.