Hello,
I am a new user of Rstan and I’m trying to compute an inference on a logistic growth model (of a mycelium). I had some troubles with the real / vector division, I wrote my model again as a loop but it’s stil not working. Here is the model, where t_i is the time and \alpha, \gamma and k are the parameters I want to infer and q_i is the mycelium quantity.
q_i \sim \mathcal{N}\left( \frac{(\alpha-\gamma)}{\alpha-\gamma-\gamma \times k) \times \exp{((\gamma - \alpha) \times t_i)}+\gamma \times k},~ \sigma^2 \right)
Here is how I write it in the .stan file :
data {
int N; //the number of observations
vector[N] x; //time
vector[N] y; //Mycelium quantities (from qPCR)
}
parameters {
real a;
real<lower=0> k;
real<lower=0> g;
real<lower=0> sigma;
}
model {
for(i in 1:N){
y[i] ~ normal((a-g)/((a-g-g*k)*exp((g-a)*x[i])+g*k),sigma);
}
//y~normal(k/(1+beta*exp(-a*x)),sigma); DOESN'T WORK BECAUSE OF real/vector not definded
}
Here is the way I call it from R
model<-stan(file=“Méthode des résidus normaux.stan”,data = list(N=nrow(Gdata),y=Gdata[,2],x=Gdata[,1]),pars = c(“a”,“k”,“g”,“sigma”))
Here Gdata is a matrix with two columns : the first one is the time (from 1 to 21) the second one is the Mycelium quantity (from 0 to 60 000).
And finally here is my error message :
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! file256c168d6418.cpp:10:1: error: stray ‘\303’ in program
namespace model256c5074ecf_Méthode_des_résidus_normaux_namespace {
^
file256c168d6418.cpp:10:1: error: stray ‘\251’ in program
file256c168d6418.cpp:10:1: error: stray ‘\303’ in program
file256c168d6418.cpp:10:1: error: stray ‘\251’ in program
file256c168d6418.cpp:30:1: error: stray ‘\303’ in program
class model256c5074ecf_Méthode_des_résidus_normaux : public prob_grad {
^
file256c168d6418.cpp:30:1: error: stray ‘\251’ in program
file256c168d6418.cpp:30:1: error: stray ‘\303’ in program
file256c168d6418.cpp:30:1: error: stray ‘\251’ in program
file256c168d6418.cpp:36:5: error: stray ‘\303’ in program
model256c5074ecf_Méthode_des_résidus_normaux(stan::io::var_context& context__,
^
file256c168d6418.cpp:36:5: error: stray ‘\251’ in program
file256c168d6418.cpp:36:5: error: stray ‘\303’ in program
file256c168d6418.cpp:36:5: error: stray ‘\251’ in prog
In addition: Warning message:
running command ‘C:/R/R-34~1.3/bin/x64/R CMD SHLIB file256c168d6418.cpp 2> file256c168d6418.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection