Skip to contents

The per-line step of tma's aggregation, before any summing: unordered rows are folded to the upper triangle, then the weight model is applied; ordered rows keep the directed n*n layout with the weight applied per cell.

Usage

finalize_row_connections(
  row_conn,
  n_codes,
  ordered = FALSE,
  weight = NULL,
  diagonal = FALSE
)

Arguments

row_conn

Numeric matrix (n_response_rows x n_codes^2) of per-row directed counts, i.e. apply_tensor()$row_connection_counts

n_codes

Number of codes

ordered

TRUE = keep directed n*n rows; FALSE = fold to choose(n, 2)

weight

Weight model name ("binary", "product", "sqrt", "log1p"), or TRUE/FALSE for the legacy binary flag (TRUE = "binary", FALSE = "product"). NULL (default) = "binary".

diagonal

Unordered only: keep self-connections in the folded rows, as columns A & A, A & B, B & B, ... (ordered rows always carry them)

Value

Numeric matrix (n_response_rows x n_codes^2, or x choose(n_codes, 2), or x n_codes(n_codes + 1)/2 with diagonal)

Details

Weight models are applied per line, before the unit sum (the stage legacy rENA applies weight.by): "binary" clamps each unordered count to 1 (ordered counts are left raw), "product" keeps the counts, "sqrt" and "log1p" (alias "log") transform each line's product count.