Hierarchical Gompertz model

Thanks Max.

My current model is:

\mu = A_ie^{-exp(-k(day - delay))} \\Y \sim N(\mu, \sigma) \\ A \sim N(0, 10000) \\k \sim N(0,10) \\ delay \sim N(0,10) \\\sigma \sim Student_t(3, 0, 1000)

(I hope I correctly depicted the hierarchy in the equation).

My code for this is:

data {
  int<lower=1> N;  // number of observations
  vector[N] Y;    // dependent variable
  vector[N] X;    // independent variable
  int<lower=1> N_group;   // number of groups
  int groups[N];  //  group assigments
}

parameters {
  real <lower=0>k;  // population-level effects
  real delay;  // population-level effects

  vector[N_group] A_group; // Vector of group effects
  
  real <lower=0> sigma;  // residual SD
}

transformed parameters{
  vector[N] mu; // population mean

  for (n in 1:N) {
    // initialize linear predictor term
    // compute non-linear predictor value
    mu[n] = A_group[groups[n]] * exp( -exp( -(k * (X[n] - delay))) );
  }
}

model {

  // priors
  A_group ~ normal(0, 10000);
  k ~ normal(0, 20);
  delay ~ normal(0, 20);
  sigma ~ student_t(3, 0, 1000);
  

  // likelihood
  Y ~ normal(mu, sigma);

}


Note the code it different to previous post I changed it.

Edit - actually - this code works now after I loosened the priors 😇
Edit2 - fixed formula above thanks to error pointed out by @Juan_Ignacio_de_Oyarbide