I want to check the values using print(), however, when adding this, it took a lot longer for the model to run. why is this? sometimes, the model took forever to initialize…
the only difference is the line of code 'print(lmix[c]) here…

model {
array[C] real lmix;
for (j in 1:J){
for (c in 1: C){
lmix[c] = log(alpha[c]) + bernoulli_lpmf(y[j, ] | p[c,]);
print(lmix[c]);
}
target += log_sum_exp(lmix);
}
}

If you queue up a lot of print statements, this will lead to a lot of memory usage, which can slow down the program. If your program is already slow due to difficult geometry, a coding error, or some other reason, this will likely only exacerbate the problem.

Hi I have a follow up question, I am running the following model

model {
M ~ normal(2,2);
V ~ lognormal(0,2);
int ob=1;
//real P=0;
//array[ncust] real P;
for (i in 1:ncust){
int count_i = count[i];
array[nsimu] real Pi = rep_array(0,nsimu);
for (t in 1:count_i){
for (s in 1:nsimu){
Pi[s] +=bernoulli_logit_lpmf(Initiated[ob]|Ms[ob,s]);
}
ob +=1;
}
target += log_sum_exp(Pi) - log(nsimu);
}
}

however, it shows the following error term

Logit transformed probability parameter is nan, but must be not nan! (in ‘test0825.stan’, line 66, column 16 to column 69)

this is the line with the Pi[s]. I want to check what causes this Na by looking at the Ms[ob,s] (Ms is a transformed parameter). How can I acheive this without using print?