Analysis of counts with changing rate of succes I have a large number of locations, let's say they're stores. At each store, $N_{it} \sim Pois(n_i)$ people walk through the door each week. We know the $n_i$ for each location.
Of the $N_{it}$, a certain proportion $P_{i}$ will buy something. Let's say an alarm clock. We measure the number of people who make a purchase $c_{it} \sim B(N_{it}, P_{i})$.
However: to make matters more complicated, the conversion probability is not constant, but rather a function of time. It appears to be something approximating a logistic curve for each location, with a differing rate constant $R_i$ but an overall maximum carrying capacity $P \approx 0.8$ because... not everyone has electricity? Anyway, this may be an inappropriate model for this probability, but if we decide on the logistic approximation then it would be something like
$$\frac{dP_{i}}{dt} = R_i P_{i} \left(1-\frac{P_{i}}{P}\right)$$
I have two groups of locations: one (approx $n = 6$) receiving an intervention, and one not. I want to know whether the distribution of rate parameters appears different between the two groups.
I have absolutely no idea how to model this. At the moment I'm just estimating the most recent week's conversion probabilities using something like the below. I then use a MWW test to see whether the estimates of the conversion probabilities in the intervention group seem different to the estimates of the conversion probabilities in the control group.
$$\hat{p}_{it} = \frac{c_{it}}{n_i}$$
I'm thinking that I would be best off modelling this using Stan, but I'm not sure how to go. Any suggestions (particularly references in R, as that's where I'm most comfortable!) would be gratefully appreciated!
 A: I believe I managed to model this! The stan code that I used is below.
  int<lower=0> T;                // Number of time periods
  int<lower=0> N;                // number of stores
  vector<lower=0>[N] n;          // Average number people entering a store per week n_i
  int<lower=0, upper=1> test[N]; // Whether a store is a test store or not
  int<lower=0> c[T, N];          // Number of purchases per time period
}

parameters {
  real<lower=0, upper=1> P;      // Maximum carrying capacity
  vector<lower=0>[2] r;          // Rate parameter for each group
  real<lower=0> t0[N];           // Location shift for each store's growth curve
                                 // Product introduced t=0; t0 > 0 helps with convergence
}

model {
  P ~ beta(1, 1);
  r ~ exponential(0.01);
  t0 ~ normal(0, 200);
  
  for (i in 1:N) {
    for (t in 1:T) {
      if (test[i] == 0)
        c[t, i] ~ poisson(P / (1 + exp(- r[1] * (t - t0[i]))) * n[i]);
      else
        c[t, i] ~ poisson(P / (1 + exp(- r[2] * (t - t0[i]))) * n[i]);
    }
  }
}

I have also experimented with just estimating a distribution for t0 within each group by replacing real t0[N] by vector[2] t0 in the parameters, and then t0[i] by t0[1] or t0[2] as appropriate in the model. Both seem to give reasonable results, although the additional constraints on t0 seem to overwhelm my ability to estimate P, which is interesting.
