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

Interface for defining which prior log densities are stored for priorsense #1585

Open
avehtari opened this issue Jan 20, 2024 · 5 comments
Open
Labels

Comments

@avehtari
Copy link
Contributor

Currently, brms stores all prior log densities in lprior variable. This is fine as the default behavior and makes it easy to use priorsense for quick tests without increasing the memory usage too much. To be able to focus on specific priors, we could allow priors to be tagged with labels.

For example, using a modified version of the example from set_prior doc

make_stancode(rating ~ treat + period + carry + (1|subject),
              data = inhaler, family = cumulative(),
              prior = c(prior(normal(0,10), class = "b", lprior = "b"),
                        prior(normal(1,2), class = "b", coef = "treat", lprior = "treat"),
                        prior(cauchy(0,2), class = "sd", group = "subject", coef = "Intercept"))

This would store the corresponding priors in variables lprior_b and lprior_treat. The same tag could be used for several priors, in which case the log density contributions from those priors would be summed together.

ping @n-kall

@n-kall
Copy link

n-kall commented Jan 20, 2024

In the separate_scaling branch of priorsense I have implemented the selection of priors and likelihood contributions in the case that lprior and log_lik are arrays. Currently the user needs to keep track of which element of the array corresponds to which prior, but perhaps the mapping can be stored.

@avehtari
Copy link
Contributor Author

Any update on possible progress on this? More people are using priorsense with brms and hierarchical models, and they get prior-likelihood conflicts reported, and our advice is to choose which priors to scale, but currently it requires editing the Stan code.

@paul-buerkner
Copy link
Owner

paul-buerkner commented Nov 27, 2024 via email

@avehtari
Copy link
Contributor Author

Would this be something that someone else could implement? I think your input would be required to decide how the user interface would be like, and of course any guidance on the brms internals would be appreciated

@paul-buerkner
Copy link
Owner

I like the user interface you proposed in terms of an lprior argument to the prior functions. Internally, upon defining the lprior_ variables one would have to then first identify which parameters belong to which lprior and then add the contribution there accordingly. likely inside the stan_prior function.

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