My aim is to perform a bayesian analysis of my model that is written in R. I would like to use Stan to do so. More specifically, I would like to use the Rstan package in R.

My model is made of 128 differential equations which depends on 8 parameters \theta. It thus represents a vector dx of length 128. It is resolved with a C++ algorithm using the Rcpp package in R. This gives a vector x of length 128 for each time step. As there are 100 timesteps, this will give overall a matrix with 128 rows and 121 columns. We will next use the 1st, 13th, 25th, 37th, …, 121st elements of the first row of this matrix in order to compute the likelihood l. I will call this vector of length 11 \tilde{\lambda}. It will be compared to a vector of observations y of length 11 by assuming a Poisson distribution. The likelihood is thus:

L(\theta)=P(y_1|\lambda=\tilde{\lambda_1}) \cdots P(y_{11}|\lambda=\tilde{\lambda_{11}})

with P() a Poisson distribution.

I want now to do a bayesian analysis. But to do this, I have to specify my model in the .stan file. The problem is that it would be too complex to rewrite the whole model (the differential equations) in C++ in the .stan file. Do you have ideas how to specify my model in Stan without rewriting it in C++?