| 1 | # Listings language drivers for BUGS, JAGS, and Stan |
| 2 | |
| 3 | [](https://www.ctan.org/pkg/lstbayes) |
| 4 | [](https://www.ctan.org/pkg/lstbayes) |
| 5 | |
| 6 | Adds support for the following languages to the LaTeX |
| 7 | [listings](http://www.ctan.org/pkg/listings/) |
| 8 | package, which pretty-prints source code: |
| 9 | |
| 10 | - [BUGS](http://www.openbugs.net) |
| 11 | - [JAGS](http://mcmc-jags.sourceforge.net/) |
| 12 | - [Stan](http://mc-stan.org/) |
| 13 | |
| 14 | # Usage |
| 15 | |
| 16 | To use, load the package |
| 17 | ```latex |
| 18 | \usepackage{lstbayes} |
| 19 | ``` |
| 20 | Then use `BUGS`, `JAGS` or `Stan` as a language in one of the listings environments or commands. For example, to format the Stan [Eight schools](https://raw.githubusercontent.com/wiki/stan-dev/rstan/8schools.stan) model, |
| 21 | ```latex |
| 22 | \begin{lstlisting}[language=Stan] |
| 23 | data { |
| 24 | int<lower=0> J; // number of schools |
| 25 | real y[J]; // estimated treatment effects |
| 26 | real<lower=0> sigma[J]; // s.e. of effect estimates |
| 27 | } |
| 28 | parameters { |
| 29 | real mu; |
| 30 | real<lower=0> tau; |
| 31 | real eta[J]; |
| 32 | } |
| 33 | transformed parameters { |
| 34 | real theta[J]; |
| 35 | for (j in 1:J) |
| 36 | theta[j] <- mu + tau * eta[j]; |
| 37 | } |
| 38 | model { |
| 39 | eta ~ normal(0, 1); |
| 40 | y ~ normal(theta, sigma); |
| 41 | } |
| 42 | \end{lstlisting} |
| 43 | ``` |
| 44 | |
| 45 | Also see the examples in `examples.tex` and `examples.pdf` files included in this repository. |
| 46 | See the `listings` [documentation](https://www.ctan.org/pkg/listings/) for more on how to use the `listings` package. |
| 47 | |
| 48 | # Issues |
| 49 | |
| 50 | Development occurs on github at <https://github.com/jrnold/lstbayes>. |
| 51 | |
| 52 | |
| 53 | <!-- LocalWords: lstbayes tex usepackage lstlisting pdf |
| 54 | --> |