ENA and ONA with RS.data
rena-demo.RmdThis article walks through fitting a standard ENA
(undirected) model and an ONA (directed) model from the
built-in RS.data dataset, then rendering both as live
interactive plots with qeviz.
Data and model setup
units_by <- c("Condition", "UserName")
codes <- c(
"Data", "Technical.Constraints", "Performance.Parameters",
"Client.and.Consultant.Requests", "Design.Reasoning", "Collaboration"
)
hoo_rules <- tma::conversation_rules(
(Condition %in% UNIT$Condition) & (GroupName %in% UNIT$GroupName)
)
context_model <- tma::contexts(
RS.data,
units_by = make.names(units_by),
hoo_rules = hoo_rules
)
multidim_arr <- tma::context_tensor(
RS.data,
sender_cols = NULL,
receiver_cols = NULL,
default_window = 8,
default_weight = 1
)
result_ena <- tma::accumulate(
tensor = multidim_arr,
codes = codes,
context_model = context_model,
ordered = FALSE
)
result_ona <- tma::accumulate(
tensor = multidim_arr,
codes = codes,
context_model = context_model,
ordered = TRUE
)
ena_set <- rENA::model(result_ena)
ona_set <- rENA::model(result_ona, directed = TRUE)Creating a plot object
qe_plot() wraps a set object in a qe_plot
that can be passed through the chain API. No rendering happens yet — the
plot is fully lazy.
Inspect what groups and units are available:
Standard ENA (undirected)
Show both group mean networks overlaid. Each chain call returns a new
qe_plot — the original is unchanged.
p <- qe_ena |>
qe_group() |> # show all group means + CI
qe_edges(qe_groups(qe_ena)[1],
also = qe_groups(qe_ena)[2]) # overlay both networks
pCompare groups by subtraction — positive weights favour the first group, negative weights favour the second:
ONA (directed)
Directed edges are rendered as tapered arrows whose apex points toward the stronger directional contributor.
Individual unit networks
Use qe_units() to list unit IDs, then pass one to
qe_edges(unit = ...). The group mean markers stay visible
so the individual network can be read in context.
Adding unit points
qe_points() overlays the individual unit scatter
dots:
Label control
qe_labels() controls label visibility for nodes, group
means, and unit points independently. Accepted values:
"on", "off", "click",
"auto".
Explicit data and plot settings (qeviz 0.5)
Networks, points and means can also come straight from data, as
rENA’s ena.plot.network() / ena.plot.points()
/ ena.plot.group() take them. Explicit layers are drawn on
the model’s scales, so widths and colours stay comparable with the
name-based plots above.
g1 <- as.matrix(ena_set$line.weights[ena_set$line.weights$Condition == qe_groups(qe_ena)[1]])
first_half <- ena_set$points[ena_set$points$GMR1 > 0] # means rotation: GMR1 is dimension 1
qe_plot(ena_set, title = "Units with GMR1 > 0", group_col = "Condition",
dims = c("GMR1", "SVD2"), range = "network") |>
qe_edges(weights = colMeans(g1), threshold = 0.05) |>
qe_points(points = first_half, color = "#555555") |>
qe_group(points = first_half, label = "GMR1 > 0", intervals = "crosshairs") |>
qe_labels(nodes = "on", font_size = 13)Exporting standalone files
qe_export_html() writes a self-contained HTML file — no
server or internet connection required:
qe_export_html(qe_ena |> qe_group() |> qe_edges(qe_groups(qe_ena)[1]),
"ena_plot.html")
qe_export_html(qe_ona |> qe_group() |> qe_edges(qe_groups(qe_ona)[1]),
"ona_plot.html")Branching from a common base works naturally since each chain call copies the plot:
base <- qe_ena |> qe_group()
qe_export_html(qe_edges(base, qe_groups(qe_ena)[1]), "group1.html")
qe_export_html(qe_edges(base, qe_groups(qe_ena)[2]), "group2.html")
qe_export_html(qe_edges(base, unit = qe_units(qe_ena)[1]), "unit1.html")