On Saturday, 20 February 2016 at 20:39:58 UTC, bachmeier wrote:

I looked at rstan. I've heard of it but never used it. AFAICT, the computationally intensive part is done by the call to stan() from within the R code. Therefore there are no efficiency issues with calling D -> R -> stan.

I took the easy road and ran the given R code directly. Here is my program:


stanOutput is a D struct holding a pointer to that particular part of the output. Without more knowledge of rats_fit, I can't go further. You could also pass D data into R (y, x, xbar, ...) but I didn't see a reason to do that here. Nonetheless this is what you want, a way to call rstan from D, and then access the results from your D program.

Very cool!

I like and recommend Stan because you can fit types of models that would be very difficult to implement any other way. It was originally developed to fit hierarchical/multi-level models.

You're right that the computationally intensive part is not in R. You write a .stan file that contains the model you want to fit. Calling the stan function in R compiles the .stan file to C++ and runs, then it gives you some output.

rats_fit stores everything from when stan fit the rats.stan model to the data. The getting started page on github
shows some of the key ways that you would interact with it. Print and plot. The extract function is also key. That's used to pull out the simulated values from the HMC.

Reply via email to