mjskay / tidybayes

Bayesian analysis + tidy data + geoms (R package)
http://mjskay.github.io/tidybayes
GNU General Public License v3.0
712 stars 59 forks source link

Add fitted draws for multivariate ordinal models #265

Closed JCruk closed 4 years ago

JCruk commented 4 years ago

I have a hierarchical ordinal multivariate model in brms and would like to plot out the fitted draws and predictions. There are two response variable both on a 3-point scale.

When I use

add_fitted_draws(data, mv_ord_mod)

or

add_fitted_draws(data, mv_ord_mod, dpar = TRUE)

I get a .category column representing the ordinal responses, but only a single .value.

Is there a way to identify which of the response variables is being reported? Is it possible to return a .response column to indicate which variable each row represents?

JCruk commented 4 years ago

I found add_fitted_draws accepts "resp" as an additional argument and I can add a variable with the response name repeated.

mjskay commented 4 years ago

Ah glad you were able to figure it out!

I might want to have a nicer way of doing this in the future, but I think it will wait on changes in {posterior}...

ASKurz commented 3 years ago

Along these lines, would it be possible to have add_fitted_draws() return a column specifying the response names? I'm working on a project with this exact issue--a multivariate ordinal model--and man would it be nice if this was clarified in the output.

JCruk commented 3 years ago

Along these lines, would it be possible to have add_fitted_draws() return a column specifying the response names? I'm working on a project with this exact issue--a multivariate ordinal model--and man would it be nice if this was clarified in the output.

One approach that worked for me was to pass the resp = "var" argument and then add a mutate(VarName = "Response") for each response andrbind` them together