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.
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 likerow_centered_matrixandcol_centered_matrix(and perhapsrow_centred_matrixandcol_centred_matrixas 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’
parameterswith standard normal priors and then construct the actual parameters in thetransformed parametersblock 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_vectortype alone. TheNraw parameter vectors (let's say of dimensionK) have to be stored asarray[K] sum_to_zero_vector[N]. This structure needs to be pulled apart and restructured asmatrix[K, N]orarray[N] vector[K]intransformed parametersin order to be multiplied by acholesky_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.