RStan/knitr Best Practices

I put together my first RStan/knitr case study: https://github.com/betanalpha/knitr_case_studies/tree/master/divergences_and_bias. Comments on the case study itself are welcome, but I mostly wanted to solicit comments about the RStan and knitr coding. Except for the graphics – I’m not touching ggplot, so base graphics it will be.

Thanks.

I can definitely take a look at the RStan and knitr coding. Probably not until after the conference though.

I’m new to knitr, so I just comment the case study itself as it is excellent!

Aki

betanalpha Developer
January 19
I put together my first RStan/knitr case study: https://github.com/betanalpha/knitr_case_studies/tree/master/divergences_and_bias. Comments on the case study itself are welcome, but I mostly wanted to solicit comments about the RStan and knitr coding. Except for the graphics – I’m not touching ggplot, so base graphics it will be.

I can help with ggplot. The doc’s terrible, but the
package is awesome, especially if you need to facet.
And it solves those problems you were having in your class
with bad scaling—ggplot is way better than base graphics
at this.

  • Bob

xlabs have “Adept delta” instead of “Adapt delta”

Aki

I’d be happy to help out with ggplot2 as well.

Jonah fixed a bunch of my non-idiomatic R, so maybe
if he has time you can get him to look at yours.

But if R style’s the only issue, I’d say just put it up
now and if you get feedback on the R, you can change it.
Your call, but this is something I think a lot of people
would like to see sooner rather than later.

  • Bob

I can definitely go over all of the R code as soon as I recover from the
past few days. I’m going to let most of my brain remain off today but I’ll
be back at it tomorrow.

Do you display the stan in the article? If you are, I couldn’t see how you are doing it.

I put things like this into my .Rmd file

~~~~{.CPP include="lr-changepoint.stan"}
~~~~

and then use a custom pandoc filter to actually pull in the stan. Sadly I don’t get any syntax highlighting and I can’t intersperse text with the stan code. Here’s an example of what you get

If you have a better way of doing this I would be very interested.