Replace Inf with 0 under generated quantities block Rstan

My result showing Inf in some parameters of yff[1], yff[2],… (see screenshot) and I want to use is_Inf() under rstan or replace Inf with 0 of iteration posterior samples of yff[i] under generated quantities block? Please help how to work out? I run the following code:

generated quantities{
  real<lower=0,upper=1> u[19];
  real yff[19];
  for (i in 1:19) {
    u[i]=beta_rng(p,q);
    yff[i]=muf[i]*(tgamma(p)*tgamma(q)/((tgamma(p+1/a)*tgamma(q-1/a))))*(u[i]/(1-u[i]))^(1/a);
  }
}

The result is:

Hey there!

You could add this

if (yff[i] == positive_infinity())
    yff[i] = 0;

after your yff calculation.

Cheers,
Max

2 Likes