stan-dev / rstanarm

rstanarm R package for Bayesian applied regression modeling
https://mc-stan.org/rstanarm
GNU General Public License v3.0
389 stars 133 forks source link

loo_subsampling for rstanarm #433

Open MansMeg opened 4 years ago

MansMeg commented 4 years ago

Summary:

Implement loo subsampling (and loo approximate posterior) for rstanarm

Description:

I got a question on how to use loo subsampling with rstanarm (see here: https://discourse.mc-stan.org/t/extract-log-likelihood-function-from-rstanarm-model/14668/3).

I then realized I should implement this for rstanarm users in addition to brms users. The question is more or less how to do this in the optimal way. I see two ways:

  1. Expose the ll_fun() (or a wrapper as log_lik_function()) as a part of the API. Then the users can plug it in in the loo subsample themselves.
  2. Implement a loo_subsampling.stanreg function.

I do not think 1 and 2 are mutually exclusive. Maybe start with exposing a log_lik_function() function? This is probably quite quick to do (I can fix). Then I can implement 2 for the models where loo currently uses the ll_fun function.

Since I'm not very familiar with the rstanarm framework and I'm not sure about all parts so it would be great to get some feedback on how to connect loo subsampling to rstanarm in the best way.

jgabry commented 4 years ago

Hey @MansMeg thanks for starting to think about this. I agree it would be good to get this working with rstanarm. I haven't had time to do this yet but if you do have time to work on it that would be great! I'm ok with your plan of starting with 1 and then moving to 2 eventually. Happy to answer specific implementation questions if you have them, or set up a time to have a call to discuss.

MansMeg commented 4 years ago

Alright! Cool. Then I'll do like this, I try to get a rough PR going for the most simple cases in the first step and then we can discuss and extend from there. I'm not super-familiar with rstanarm. Great!

jgabry commented 4 years ago

Great thanks @MansMeg!