Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make moment_match work natively with cmdstanr #1556

Open
paul-buerkner opened this issue Oct 30, 2023 · 4 comments
Open

Make moment_match work natively with cmdstanr #1556

paul-buerkner opened this issue Oct 30, 2023 · 4 comments
Labels
Milestone

Comments

@paul-buerkner
Copy link
Owner

Currently, brms switches to rstan backend to make moment matching happen in loo(). However, with log_prob and friends now being available in cmdstanr too, models fit with cmdstanr no longer have to be recompiled in rstan. This is particularily relevant as moment matching regularily crashes the R session when using rstan 2.26 or 2.32.

@paul-buerkner paul-buerkner added this to the 2.21.0 milestone Oct 30, 2023
@andrjohns
Copy link
Contributor

FYI (if you didn't already know) as of cmdstanr 0.6.0 moment-matching is available in the $loo() method (i.e., fit$loo(moment_match = TRUE)), with example usage in the tests

@paul-buerkner
Copy link
Owner Author

Thank you! I didn't know but I am sure this will be very helpful!

@n-kall
Copy link

n-kall commented Jan 18, 2024

A solution to this could also help with what @topipa and I are trying to do with iwmm, see topipa/iwmm/issues/4
We've been thinking about the best way to handle moment matched brmsfit objects (e.g. how to store weights, replacement of draws with moment matched draws) and there is a work in progress moment_match.brmsfit method assuming rstan backend (this is for generic moment matching, not just loo).

@paul-buerkner
Copy link
Owner Author

I don't think I will be able to implement this feature in brms 2.21. More like in 3.0. The reason is that using moment matching with cmdstanr requires the cmdstanr objects, which are currently not stored but converted to rstan objects. In brms 3.0 we should change this policy by always storing the object provided by the backend used to fit the model. This comes with quite a few other necessary changes so I don't think I can make this possible now.

@paul-buerkner paul-buerkner modified the milestones: 2.21.0, brms 3.0 Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants