How to combine rstan code with R code?

mcmc

#1

I’m doing MCMC to produce a chain of some parameters.
For convenient, I just assume they are \gamma, \theta and \beta.

I’m my model, since \gamma is a integer and can’t be marginalized out it,I can only do MCMC in following way.

1:update \gamma by using R code.

2:update \theta by using Rstan.

3:update \beta by using R code.

But this can not carry out the right result, since everytime I use Rstan, I need to input data and these data should be raw data. However, I can only get the data from previous step.

Is there anyway to use only part of stan? Because I think tuning parameters has done very well in stan, and if I write my own HMC code it would be hard to tuning parameters right and get a right result.


#2

That is going to be very difficult to do correctly and even then, the results probably won’t me meaningful with a finite number of iterations. It is going to be easier to overcome whatever makes it such that \gamma “can’t be marginalized out”.