distribute_matrix_across_clusters: Helper function to turn a cluster-level matrix into an...

View source: R/quadratic_forms.R

distribute_matrix_across_clustersR Documentation

Helper function to turn a cluster-level matrix into an element-level matrix by duplicating rows or columns of the matrix

Description

Turns a cluster-level matrix into an element-level matrix by suitably duplicating rows or columns of the matrix.

Usage

distribute_matrix_across_clusters(
  cluster_level_matrix,
  cluster_ids,
  rows = TRUE,
  cols = TRUE
)

Arguments

cluster_level_matrix

A square matrix, whose number of rows/columns matches the number of clusters.

cluster_ids

A vector of cluster identifiers. If rows=TRUE, the number of unique elements of cluster_ids must match the number of rows of cluster_level_matrix. If cols=TRUE, the number of unique elements of cluster_ids must match the number of columns of cluster_level_matrix.

rows

Whether to duplicate rows of the cluster_level_matrix for elements from the same cluster.

cols

Whether to duplicate columns of the cluster_level_matrix for elements from the same cluster.

Value

The input cluster_level_matrix has its rows/columns duplicated so that the number of rows (if rows=TRUE) or columns (if cols=TRUE) equals the length of cluster_ids.


bschneidr/svrep documentation built on Feb. 11, 2025, 4:24 a.m.