Case study: Extreme value analysis and user defined probability functions in Stan


I made a notebook which demonstrates how to define probability functions in Stan language and use them for building the model, ppc, loo and predictions. I use geomagnetic storms and generalized Pareto distribution as an example. The notebook geomagnetic.Rmd is in github

And for easier viewing here’s a pdf
geomagnetic.pdf (427.7 KB)

Any feedback is welcome. I’m not certain if there is enough for a Stan case study, but at least this should be useful example for defining user defined probability distributions.

Coding a translated / 3-parameter Weibull

I made an update of the notebook. I made several miscellaneous improvements. @bgoodri gave a great suggestion to add tests, which was very easy using expose_stan_functions. Update in github and here’s the pdf, too
geomagnetic.pdf (437.0 KB)

Would this be ok as a case study?


Great new (for me). I am am working on weather extremes (rare events) and this is definitely (super) useful. Thank you @avehtari !


Many thanks indeed. That has saved me many hours of work.


The case study is now up at
and repo was moved to

Thanks @bgoodri, @bbbales2, @Bob_Carpenter for comments.