int Nsurv_ppc[n_N];
int Nsurv_sim[n_N];
int Nsurv_sim_prec[n_N];

vector[n_N] log_lik;

for(g in 1:n_group){
  /* binomial_rng function cannot be vectorized, so we need to use a loop*/
   for(i in GROUP_N[1,g]:GROUP_N[2,g]){
     Nsurv_ppc[i] = binomial_rng(Nprec[i], Conditional_Psurv_hat[i]);
     Nsurv_sim_prec[i] = i == GROUP_N[1,g] ? Nprec[i] : Nsurv_sim[i-1] ;
     Nsurv_sim[i] = binomial_rng(Nsurv_sim_prec[i], Conditional_Psurv_hat[i]);
     log_lik[i] = binomial_lpmf(
        Nsurv[GROUP_N[1,g]:GROUP_N[2,g]] | 
        Nprec[GROUP_N[1,g]:GROUP_N[2,g]], 
        Conditional_Psurv_hat[GROUP_N[1,g]:GROUP_N[2,g]]
     );
   }
}
