Hi all,
I am running the following code, which initially instead of a normal distribution I was using a lognormal but it gave me the same error, which is:
Chain 1 Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Chain 1 Exception: normal_lpdf: Location parameter is nan, but must be finite! (in ‘C:/Users/IGARCI~1/AppData/Local/Temp/Rtmpm8knEn/model-29941dda214a.stan’, line 50, column 4 to column 40)
Removing the exp function does not solve this either. This is causing issues because it takes too long to converge, and I do not really know what is causing this nas, even if I had defined parameter constraints in the code.
I have also used in R in order to sample the step_size function, which has not solve this either:
cmd_fit ← modelcmd$sample(
- step_size= 0.1, data = datalist,*
- seed = 42L,*
- refresh = 0)*
Any ideas on how can I fix this?
functions {
vector model3(real t, vector y, real pAB, real uAB, real uASC) {
vector[2] dydt;
dydt[1] = pAB*y[2]-uAB*y[1];
dydt[2] = -uASC*y[2];
return dydt;
}
}
data {
int <lower=1> nobs;
real t0;
vector[2] y0;
real ts[nobs];
int <lower=1> indivs;
real <lower=0> antib[nobs];
//real <lower=1, upper=indivs> subj[nobs];
}
parameters {
real <lower=0> pAB0;
real <lower=0> uAB;
real <lower=0> uASC0;
real <lower=0> sigma;
real <lower=0> sigmapAB;
real <lower=0> sigmauASC;
//real <lower=0> rpABmu;
//real <lower=0> ruASCmu;
real <lower=0> rpAB[indivs];
real <lower=0> ruASC[indivs];
}
model {
vector[2] yhat[nobs];
//prior distributions
pAB0 ~ normal(0.5, 0.5);
uASC0 ~ normal(0.5, 0.5);
//rpABmu ~ normal(0, 0.001);
uAB ~ normal(0, 0.001);
//ruASCmu ~ normal(0, 0.001);
sigmapAB ~ inv_gamma(0.01, 0.01);
sigmauASC ~ inv_gamma(0.01, 0.01);
sigma ~ inv_gamma(0.01, 0.01);
for (j in 1:indivs) {
real pAB = exp(pAB0)*exp(rpAB[j]);
real uABt = uAB;
real uASC = exp(uASC0)*exp(ruASC[j]);
yhat = ode_rk45(model3, y0, t0, ts, pAB, uABt, uASC);
//likelihood
for (i in 1:nobs) {
antib[i] ~ normal(yhat[i,2], sigma);
rpAB[j] ~ normal(0.1, sigmapAB);
ruASC[j] ~ normal(0.1, sigmauASC);
}
}
}
generated quantities {
real z_pred[nobs];
for (t in 1:nobs){
z_pred[t] = normal_rng(antib[t], sigma);
}
}