Hello, I have a problem evaluating an integral. The error is about ill-type arguments for integrate_1d function. I double check with the Stan documentation and some forum discussions, but still, I got the same error.
This is my Stan script:
functions {
real integrand_fgd(real u, real xc, real[] theta, real[] x_r, int x_i) {
real mu = theta[1];
real sigma = theta[2];
real ti = theta[3];
real a = (mu/sigma) * (mu/sigma);
real b = mu/(sigma*sigma);
real gt = gamma_lpdf(u| a, b) + gamma_lpdf(u-ti| a, b);
return exp(gt);
}
}
data {
int N;
vector[N] x;
// prior parameter
vector[2] pr_sigma;
vector[2] pr_mu;
}
transformed data {
real x_r[0];
int x_i[0];
}
parameters {
real<lower=0> mu;
real<lower=0> sigma;
}
model {
//prior
target += inv_gamma_lpdf(sigma| pr_sigma[1], pr_sigma[2]); //prior of sigma
target += normal_lpdf(mu| pr_mu[1], pr_mu[2]) - normal_lccdf(0| pr_mu[1], pr_mu[2]); //prior for mu
for(i in 1:N) {
real left_limit = x[i];
target += log(2) + log(integrate_1d(integrand_fgd,
left_limit,
positive_infinity(),
{mu, sigma, left_limit},
x_r, x_i, 1e-8));
}
}