Using segment function for bernoulli_logit

I am trying to use the segment function to break up my ragged occupancy dataset. However, it appears the data is not being passed through the bernoulli_logit§ portion of the model.
Thank you

data {
  int<lower=0> N; //of observations/ # temporal replication
  int<lower=0> K; // of groups/ # of arrays
  int pos[K]; // position of the first detection of each group
  int y[N]; // observations/ Detection at each site for all temporal replication
  int s[K]; // group size s={45,42,42,41,54,...}
  int x[K]; // Observed occupancy at each site
  vector[K] t_burn;
  vector[N] air_temp; 

parameters {
  real a_psi;
  real b1_psi;
  real a_p; 
  real b1_p;

transformed parameters {
  vector[K] logit_psi;
  vector[N] logit_p;
  logit_psi = a_psi + b1_psi * t_burn;
  logit_p = a_p + b1_p * air_temp;
model {
  // Priors
  a_psi ~ normal(0, 1); 
  b1_psi ~ normal(0,1); 

  a_p ~ normal(0, 1);
  b1_p ~ normal(0, 1);

// Likelihood

  for (i in 1:K) {
      if (x[i] == 1) {    // Occurred and observed
      1 ~ bernoulli_logit(logit_psi[i]);
      segment(y, pos[i], s[i]) ~ bernoulli_logit(logit_p[i]); 
    } else {
                            // Occurred and not observed
      target += log_sum_exp(bernoulli_logit_lpmf(1 | logit_psi[i])
                            + bernoulli_logit_lpmf(0 | logit_p[i]),
                            // Not occurred
                            bernoulli_logit_lpmf(0 | logit_psi[i]));

I guess it’s a bit crude, but the easiest way I can think of testing this is to add print statements:

print(segment(y, pos[i], s[i]));
segment(y, pos[i], s[i]) ~ bernoulli_logit(logit_p[i]);

If this is getting evaluated and the segment is indexing stuff, you’ll see a lot of numbers get printed out, if this either isn’t getting evaluated or the indexing isn’t doing what you expect, you won’t.

Thanks bbbales2,

The segment function is indexing correctly. It isn’t getting evaluated how I expect.