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 https://github.com/avehtari/BDA_R_demos/blob/master/demos_rstan/

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.

7 Likes

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 https://github.com/avehtari/BDA_R_demos/blob/master/demos_rstan/ and here’s the pdf, too
geomagnetic.pdf (437.0 KB)

Would this be ok as a case study?

3 Likes

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

1 Like

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

1 Like

The case study is now up at http://mc-stan.org/users/documentation/case-studies/gpareto_functions.html
and repo was moved to https://github.com/avehtari/BDA_R_demos/tree/master/demos_rstan/gpareto_functions

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

1 Like