model {
  # data
  ## int<lower=1> n_vars
  ## int<lower=1> train_n_sites
  ## real sens
  ## real spec
  ## real[train_n_sites, n_vars] train_model_matrix
  ## real[train_n_sites] train_n_obs
  ## matrix[train_n_sites, max(train_n_obs)] train_obs

  # priors
  lambda ~ dunif(0.001, 10)     # regularization parameter
  coefs[1] ~ dnorm(0, 0.001)    # intercept parameter
  for (i in 2:n_vars) {
    coefs[i] ~ ddexp(0, lambda) # covariate parameters
  }

  # transformed parameters
  for (i in 1:train_n_sites) {
    logit(yhat[i]) <- coefs %*% train_model_matrix[i, ]
  }

  # likelihood
  for (i in 1:train_n_sites) {
    occ[i] ~ dbern(yhat[i])
    for (j in 1:train_n_obs[i]) {
      train_obs[i, j] ~ dbern((occ[i] * sens) + ((1 - occ[i]) * spec))
    }
  }
}
