JWiley / brmsmargins

Average marginal estimates for Bayesian models fit with the brms package
https://joshuawiley.com/brmsmargins
Other
20 stars 2 forks source link

support multivariate outcomes #6

Open JWiley opened 2 years ago

JWiley commented 2 years ago

Currently brmsmargins does not support any outcome where a call to fitted() would produce more than one value for one input. This means that multivariate models and models like zero-inflated models that have a predicted probability of being zero / non-zero and then predicted value if not zero are not supported.

qdread commented 1 year ago

+1, this would be extremely helpful. I just looked on this repo to see if anything like this was in the works because I would love to use brmsmargins for a model with family=categorical. Is there any way I can help out implementing this?

JWiley commented 1 year ago

I’ve been looking at what this will take. It’s a fairly large update because currently we integrate over the random effects code in C++ which isn’t my strength but is generally faster. Anyway for multivariate outcomes, the framework needs to change to accommodate multiple sets of (possibly correlated) random effects.

I’m not sure where your R coding is at, but two things that could help this is:

(1) if you could create some R code that draws from the (multivariate) normal random effects distributions specified by a multivariate model and multiplies that by the appropriate matrix extracted from brms. I’ve not looked in depth at brms but assume they must structure or name the random effects design matrix differently when accommodating multivariate outcomes.

(2) A smaller task: make the simplest inverse transformation function possible in R using basic arithmetic. This will be a template I translate and can use to double check the C++ implementation.

Alternately, I’d you’re happy to work in C++ let’s talk more because I know conceptually what to do but it’s a bit slow and hard for me to write in C++.

On Sat, Jul 16, 2022 at 00:17 Quentin Read @.***> wrote:

+1, this would be extremely helpful. I just looked on this repo to see if anything like this was in the works because I would love to use brmsmargins for a model with family=categorical. Is there any way I can help out implementing this?

— Reply to this email directly, view it on GitHub https://github.com/JWiley/brmsmargins/issues/6#issuecomment-1185591902, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACOZHB5P3I7KLHZBSMJ4KTVUFXJJANCNFSM5T2OLF6Q . You are receiving this because you were assigned.

qdread commented 1 year ago

Sadly my C++ skills are nonexistent but I believe I could take a stab at either or both of those R tasks. I will try to take a look at the relevant brms code sometime in the next couple of weeks.