Hi There,
I am trying to fit a poisson distribution with GP model in Stan. I have done it with Normal likelihood sucessfully. However when I change the likelihood with Poisson_Log then I get receive for that part.
The stan gaves me the error that:
Real return type required for probability function.
error in ‘model3b084954e90_GP_Zacc_LikeLihood_Change’ at line 42, column 30
40: sigma_f ~ normal(4, 1);
41:
42: yn ~ poisson_log(f_predict);
^
43: }
here is my stan code:
int<lower=1> N; // number of observation
vector[N] x; // univariant Covariate
vector[N] y; // Target Variable
int<lower=1, upper=N> observed_idx[N];
}
transformed data {
// normalize data
real xmean = mean(x);
real ymean = mean(y);
real xsd = sd(x);
real ysd = sd(y);
real xn[N] = to_array_1d((x - xmean)/xsd);
vector[N] yn = (y - ymean)/ysd;
real sigma_intercept = 0.15; // Changed from 0.1
vector[N] jitter = rep_vector(1e-8, N);
//vector[N] jitter = rep_vector(1e-7, N); // 1e-e9
}
parameters {
real<lower=0> lengthscale_f; // lenght scale of f
real<lower=0> sigma_f; // scale of f
vector[N] z_f;
}
transformed parameters {
matrix[N, N] cov = cov_exp_quad(xn, lengthscale_f, sigma_f)
+ diag_matrix(rep_vector(1e-10, N));
matrix[N, N] L_cov = cholesky_decompose(cov);
vector[N] f_predict = L_cov * z_f;
}
model {
z_f ~ normal(0, 1);
lengthscale_f ~ lognormal(-3.0, 0.2);
sigma_f ~ normal(4, 1);
yn ~ poisson_log(f_predict[observed_idx]);
}
generated quantities {
int y_predict[N] = poisson_log_rng(f_predict);
}
Can anyone give me an insight of this error?