Skip to contents

Given a \(p \times L\) matrix theta, this function redistributes the row sums into a new matrix of the same shape where each row's total effect is placed into a single column (using round-robin assignment).

This operation is useful for decomposing a combined effect vector into sparse single-effect columns (e.g., in spike-and-slab regression or additive effect models).

Arguments

theta

A numeric matrix of shape p × L.

L

Integer. Number of columns in the output matrix.

Value

A numeric matrix of shape p × L, where each row sum matches the corresponding row sum of theta, and each row has only one nonzero entry.

Examples

if (FALSE) { # \dontrun{
theta <- matrix(rnorm(12), nrow = 6, ncol = 2)
theta_new <- decompose_theta(theta, L = 2)
all.equal(rowSums(theta), rowSums(theta_new))  # Should be TRUE
} # }