Hello Stan users. I started using Stan yesterday, and I still can’t figure out how to fit a Poisson Lognormal Zero-Truncated model. I will show the approach I have used. First, I have simulated some data using R:

```
set.seed(213211)
N <- 1000
lambdas <- rlnorm(N,-1,3)
site.data <- rpois(N,lambdas) # Generates 1000 samples.
```

The \lambda_i are drawn from a lognormal distribution with parameters mean of -1 and standard deviation of 3 on the log scale. I expect Stan’s estimations to be close to these values. I fitted the model using no truncation first and that estimated the parameters pretty well(\bar{\mu}\approx-1 and \bar{\sigma}\approx 2.8). I then removed all zeroes from the sample and proceeded to add what I think should be the truncation term to the Stan code. Here is how I remove the zeroes from my sample in R:

```
site.data <- site.data[site.data > 0]
```

Here is my Stan code:

```
data{
int<lower = 1> N;
int<lower = 0> y[N]; // Change the lower bound accordingly.
}
parameters{
real mu;
real<lower = 0> sigma;
vector<lower = 0>[N] lambda;
}
model{
sigma ~ cauchy(0, 5);
mu ~ cauchy(0, 3);
lambda ~ lognormal(mu,sigma);
for (n in 1:N)
{
// Remove comments to test the code.
// No truncation.
// target += poisson_lpmf(y[n] | lambda[n]);
// I have tried using the following expressions to truncate (one at a time)...
// y[n] ~ poisson(lambda[n]) T[1,];
// target += poisson_lpmf(y[n] | lambda[n]) - log1m_exp(poisson_lpmf(0 | lambda[n]));
// target += poisson_lpmf(y[n] | lambda[n]) - log1m_exp(-lambda[n]);
// target += poisson_lpmf(y[n] | lambda[n]) - poisson_lccdf(0 | lambda[n]);
}
}
```

Using the code above and the zero-truncated data, I get \bar{\mu} \approx 1.24 and \bar{\sigma} \approx 2.08. This is far from the parameters I used to generate the data. Where am I going wrong? Thanks a lot for the help!