Quasipoisson model using stan

I want to fit a quasipoisson model using stan, the code is as follows. R showed an error at the line

target += poisson_log_lpdf(y[i] | lambda[i] + X[i,]*beta);

Could anyone give some suggestions on the code? Thank you!

stan.code<-“
data {
int<lower=0> N;
int<lower=0> k;
matrix[N, k] X;
real y[N];
}
parameters {
vector[k] beta;
vector[N] lambda;
real<lower=0> tau;
}
transformed parameters {
real<lower=0> sigma;
sigma = 1.0 / sqrt(tau);
}
model {
target += cauchy_lpdf(tau | 0, 5);
target += normal_lpdf(beta | 0, 10);
for (i in 1:N) {
target += normal_lpdf(lambda[i] | 0, sigma);
target += poisson_log_lpdf(y[i] | lambda[i] + X[i,]*beta);
}
}”

It should be target += poisson_log_lpmf(...); but in that case you need to declare your outcome as int<lower=0> y[N].

You are probably going to want / need an uncentered parameterization. Also, you should get rid of that loop over N so that your model block is

target += cauchy_lpdf(tau | 0, 5);
target += normal_lpdf(beta | 0, 10);
target += normal_lpdf(lambda | 0, 1);
target += poisson_log_lpmf(y | sigma * lambda + X * beta);

Thank you Ben for your kind help!