Modeling an over-distributed Poisson distribution with normally distributed lambda value

I’m trying to describe the distribution of count data over a period of 90 days. Eventually, this will be used in an A/B test using Region of Practical Equivalence to determine the experiment outcome. We’re also looking at the magnitude of each event in a separate model, so the output will be used for decision analysis.

I tried using a simple Poisson distribution, but the posterior-predictive checks looked incorrect. The posterior distribution was very narrowly distributed while the actual data was extremely widely distributed.

As an experiment, I tried systematically adding a random variable normally distributed around zero to the lambda values produced by the model, created samples of that distribution in Numpy, and plotted them against the actual data, and was able to create a distribution that mapped perfectly to what I observed.

This makes me think that lam is not a static value, but a normally distributed value that changes each day.

I’m trying to find the mu and sigma values that best describe lambda, but it seems like my model isn’t working at all. l_mu and l_sigma don’t fit well to the lambda values produced at all. I kind of think they’re just completely random samples.

Can anyone help me figure out how to identify the mu and sigma parameters that best describe this distribution? Or offer a better way to model this?

data {
    int<lower=1> n_days;
    int action_count[n_days];
}
parameters {
    real<lower=0> l_mu;
    real<lower=0> l_sigma;
    real<lower=0> lam;
}
model {
  lam ~ normal(l_mu, l_sigma);
  for (d in 1:n_days) {
      action_count[d] ~ poisson(lam);
  }
}

Welcome!

The model as written has only one lam that is used for all days. You want a separate lam for each day.

data {
    int<lower=1> n_days;
    int action_count[n_days];
}
parameters {
    real<lower=0> l_mu;
    real<lower=0> l_sigma;
    real<lower=0> lam[n_days];
}
model {
  lam ~ normal(l_mu, l_sigma);
  for (d in 1:n_days) {
      action_count[d] ~ poisson(lam[d]);
  }
}
1 Like