Skip to content

Splines in Stan; Spatial Models in Stan !

Two case studies:

Splines in Stan, by Milad Kharratzadeh.

Spatial Models in Stan: Intrinsic Auto-Regressive Models for Areal Data, by Mitzi Morris.

This is great. Thanks, Mitzi! Thanks, Milad!


  1. harryq says:

    As a spatial statistician, this puts me one step closer to using Stan in my MS-level Bayes course, so kudos to you! (The bigger step for is me deciding whether or not I want to teach Gibbs/Metropolis and then go to software that doesn’t use Gibbs/Metropolis, but that’s my problem not yours…)

    One minor comment: In the ICAR section of Mitzi’s write-up, the joint distribution is not a normal distribution (due to D-W being singular, as you point out a few lines later), and the pairwise difference formulation is off slightly — in particular, the “1/tau^{n/2}” piece outside of the exponent should have “(n-1)/2” if you only have one “spatial island” or, more generally, “(n-I)/2” if you have I spatial islands. Similarly, if you have I spatial islands, you need to have I sum-to-zero constraints (e.g., one for the contiguous US, one for Alaska, and one for Hawaii). Jim Hodges has a 2003 paper related to this in Biometrics (“On the precision of the conditionally autoregressive prior in spatial models”).

  2. Mitzi says:

    thank you for noticing that! and thanks for pointer to the Hodges paper which is admirably clear – available at:

  3. Gregor Gorjanc says:

    There is a neat proposal on how to treat disconnected graphs in Freni-Sterrantino et al. (2017) on ArXiv: “A note on intrinsic Conditional Autoregressive models for disconnected graphs”

  4. Nick Menzies says:

    On the splines example, the math near the end shows a_1 ~ N(0,tau) and a_i ~ N(a_i-1,tau) . I dont think this is right, as it seems to assume the same variance should be used for the starting value of the spline as well as the first derivative. Also, if we are interested in smoothing, I would be tempted to smooth the second derivative rather than the first (ie curvature rather than slope), but maybe it is an empirical question as to which is more appropriate. Finally, it would be useful to link this to the established literature on p-splines (ie penalized B-splines), as it seems that is what is going on here. These are all just suggestions (and may well be wrong) — thanks for the great case study!

    PS — sorry to put the comment here, there doesnt appear to be a comment or contact link on the case studies themselves. Maybe this would be useful?

Leave a Reply