Hi there!
A couple of comments:
-
slicing any data variable is not worth it, as there are no copies happening. Copies are only made with parameters/transformed parameters. So only slicing that should show some performance improvements in your case would be with the
beta
parameter vector. -
I think you could actually just use the normal_id_glm function here: 17.2 Normal-id generalized linear model (linear regression) | Stan Functions Reference