# Advice on priorsense and splines

**URL:** <https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945>\
**Category:** General\
**Tags:** priors, splines, techniques, brms\
**Created:** [January 4, 2023, 10:03pm UTC](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945 "2023-01-04T22:03:48Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![andymilne](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andymilne/32/21046_2.png) [@andymilne](https://discourse.mc-stan.org/u/andymilne)\
**Post date:** [January 4, 2023, 10:03pm UTC](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945/1 "2023-01-04T22:03:48Z")

</div>

I am running a model in brms with a couple of smooth terms. I thought it would be interesting to use the priorsense package. It is finding several prior-data conflicts for the various smooth terms used in brms. Changing the sds priors seems to not help; indeed, I cannot find any combination of priors that doesn’t result in several prior-data conflicts. However, if I replace the smooths with cubic terms, the prior-data conflicts disappear (but the fits to the data are less convincing). I am curious to know if prior-data conflicts reported by priorsense are not actually problematic for smooth terms due to there being some form of combined/joint information being shared between the various terms.

---

<div class="post-metadata">

**Author:** ![andymilne](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andymilne/32/21046_2.png) [@andymilne](https://discourse.mc-stan.org/u/andymilne)\
**Post date:** [January 4, 2023, 11:34pm UTC](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945/2 "2023-01-04T23:34:45Z")

</div>

Tagging some of the authors of priorsense … @topipa, @paul.buerkner, @avehtari

---

<div class="post-metadata">

**Author:** ![paul.buerkner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/paul.buerkner/32/3303_2.png) [@paul.buerkner](https://discourse.mc-stan.org/u/paul.buerkner)\
**Post date:** [January 5, 2023, 8:26am UTC](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945/3 "2023-01-05T08:26:18Z")

</div>

I have no experience with using priorsense with smooth terms yet. Do you have a reproducible example that demonstrates the behavior?

---

<div class="post-metadata">

**Author:** ![avehtari](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/avehtari/32/5935_2.png) [@avehtari](https://discourse.mc-stan.org/u/avehtari)\
**Post date:** [January 5, 2023, 10:09am UTC](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945/4 "2023-01-05T10:09:47Z")

</div>

Have you looked at the GP example in [[2107.14054] Detecting and diagnosing prior and likelihood sensitivity with power-scaling](https://arxiv.org/abs/2107.14054) (updated 19 Dec 2022)? That GP implementation is practically the same as the spline implementation, so the advice there holds for splines, too.

---

<div class="post-metadata">

**Author:** ![andymilne](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andymilne/32/21046_2.png) [@andymilne](https://discourse.mc-stan.org/u/andymilne)\
**Post date:** [January 5, 2023, 5:54pm UTC](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945/5 "2023-01-05T17:54:55Z")

</div>

That’s very informative and probably corresponds to what I am seeing in my model – thank you for the pointer. I will investigate further by focussing on the sensitivity of the predictions.

---

<div class="post-metadata">

**Author:** ![jflournoy](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jflournoy/32/2238_2.png) [@jflournoy](https://discourse.mc-stan.org/u/jflournoy)\
**Post date:** [May 2, 2023, 7:15pm UTC](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945/6 "2023-05-02T19:15:33Z")

</div>

Thank you so much for your helpful reply @avehtari, Is there a code example that goes with Figure 11 by any chance?

---

<div class="post-metadata">

**Author:** ![avehtari](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/avehtari/32/5935_2.png) [@avehtari](https://discourse.mc-stan.org/u/avehtari)\
**Post date:** [May 3, 2023, 6:20pm UTC](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945/7 "2023-05-03T18:20:37Z")

</div>

Great that you asked, as the code was missing from the repo by accident.  
@n-kall just pushed to code to [powerscaling-sensitivity/case-studies/motorcycle at master · n-kall/powerscaling-sensitivity · GitHub](https://github.com/n-kall/powerscaling-sensitivity/tree/master/case-studies/motorcycle)

---

<div class="post-metadata">

**Author:** ![jflournoy](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jflournoy/32/2238_2.png) [@jflournoy](https://discourse.mc-stan.org/u/jflournoy)\
**Post date:** [May 3, 2023, 7:17pm UTC](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945/8 "2023-05-03T19:17:05Z")

</div>

Amazing code examples, @n-kall, a ton to learn from this on so many levels. I’m trying to figure out how to best use draws from `brms::posterior_epred` with `priorsense` and am a little stuck, but I’ll post a new question since that’s a bit off topic here.

---

<div class="post-metadata">

**Author:** ![jflournoy](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jflournoy/32/2238_2.png) [@jflournoy](https://discourse.mc-stan.org/u/jflournoy)\
**Post date:** [May 11, 2023, 11:24pm UTC](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945/9 "2023-05-11T23:24:38Z")

</div>

I ended up [opening an issue](https://github.com/n-kall/priorsense/issues/18) with some example code. It’s just an interface issue, really, so hopefully this helps others prior to the interface update @n-kall is working on.

---

<div class="post-metadata">

**Author:** ![karimn](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/karimn/32/4974_2.png) [@karimn](https://discourse.mc-stan.org/u/karimn)\
**Post date:** [October 20, 2024, 1:23am UTC](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945/10 "2024-10-20T01:23:44Z")

</div>

A quick question about this model: why aren’t `beta_f` and `beta_g` included in the `lprior` calculation?

---

<div class="post-metadata">

**Author:** ![n-kall](https://avatars.discourse-cdn.com/v4/letter/n/e5b9ba/32.png) [@n-kall](https://discourse.mc-stan.org/u/n-kall)\
**Post date:** [October 22, 2024, 7:57pm UTC](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945/11 "2024-10-22T19:57:30Z")

</div>

If I remember correctly, this is because the model is using a non-centered parametrisation where `beta_f` and `beta_g` have a standard normal prior and then are multiplied by the `diagSPD` terms (lines 66 and 67). Because of this it doesn’t make sense to perturb the normal(0,1) prior on these parameters but to focus on the other parameters that determine the scales.

---

<div class="post-metadata">

**Author:** ![karimn](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/karimn/32/4974_2.png) [@karimn](https://discourse.mc-stan.org/u/karimn)\
**Post date:** [October 23, 2024, 1:45pm UTC](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945/12 "2024-10-23T13:45:19Z")

</div>

Ok, I see it now. Thanks!

---

<div class="post-metadata">

**Author:** ![avehtari](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/avehtari/32/5935_2.png) [@avehtari](https://discourse.mc-stan.org/u/avehtari)\
**Post date:** [November 11, 2024, 7:08pm UTC](https://discourse.mc-stan.org/t/advice-on-priorsense-and-splines/29945/13 "2024-11-11T19:08:41Z")

</div>

I’ve been away, but wanted to add even a bit late that also in hierarchical models we need anyway to select the level of the focus and in this case we’re not interested in `beta_f` and `beta_g` as they do not have direct interpretation and they can be considered as nuisance parameters.
