stanc3
stanc3 copied to clipboard
Expose additional `normal_id_glm` pointwise signatures
The current normal_id_glm signatures for use with a univariate outcome y only support matrix type inputs for x, for example:
real normal_id_glm_lpdf(real y | matrix x, real alpha, vector beta, real sigma)
For pointwise usage, it would be great to add corresponding row_vector signatures:
real normal_id_glm_lpdf(real y | row_vector x, real alpha, vector beta, real sigma)
As the current signatures require calling to_matrix() at each iteration:
generated quantities {
vector[N] log_lik;
for (n in 1:N) {
log_lik[n] = normal_id_glm_lpdf(y[n] | to_matrix(x[n]), alpha, beta, sigma);
}
}
Is this just for convenience or do we expect different performance? I thought to_matrix was essentially free for eigen types
Mostly convenience, since the majority of use-cases with a univariate outcome would be a single set of predictors (e.g., pointwise log-likelihood), so a real y and row_vector x combo would be more common than a real y and matrix x