Skip to content

Feature request: row_centred_matrix and column_centred_matrix #3361

Description

@jaburgoyne

To facilitate working with the sum-to-zero constraint in multivariate contexts, it would be valuable to be able to specify not only individual sum_to_zero_vectors but also matrices for which all rows or all columns are constrained to sum to zero. To my knowledge, there is no universally standard name for such a mathematical object (nor to Claude's knowledge, which only produced a list of suggestions), but for the sake of starting a conversation, I would propose something like row_centered_matrix and col_centered_matrix (and perhaps row_centred_matrix and col_centred_matrix as aliases for spelling-dialect neutrality).

The primary use case for me would be hierarchical modelling with correlated multivariate random effects, e.g., random-slopes models or multivariate item-response models. To reduce problems with funnel geometries during sampling, it can be wise to write such models using ‘raw’ parameters with standard normal priors and then construct the actual parameters in the transformed parameters block via matrix multiplication with standard-deviation and correlation-matrix hyperpriors (e.g., the User's Guide chapter on ‘Regression Models’).

That's awkward to do using the sum_to_zero_vector type alone. The N raw parameter vectors (let's say of dimension K) have to be stored as array[K] sum_to_zero_vector[N]. This structure needs to be pulled apart and restructured as matrix[K, N] or array[N] vector[K] in transformed parameters in order to be multiplied by a cholesky_factor_corr[K]. In practice, the problem is mostly that this restructuring step is ugly and confusing to read, but in theory, it is also memory inefficient and could cause slowdowns at large model scale.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions