"empty slot not allowed in variable name" (OpenBUGS, R2OpenBUGS)

451 Views Asked by At

I'm a beginner with OpenBUGS which I use through the R2OpenBUGS R package. I try to set state space model for identifying a lognormal signal in very noisy data. After many trials and errors, I managed to get this code but I still get the following error message: "empty slot not allowed in variable name error pos 664" which I don't understand. Can anyone knows what is wrong with the code ?

Disclaimer:

  • alt = measured altitude
  • true_alt = what I try to assess
  • nbird = number of individuals
  • nobs = number of observations (this number is not the same for every bird)
  • nstate = 'flight state', which is the way the birds behave (nstate = 3 because there are 3 different behaviours)

I try to determine the lognormal distribution of true_alt for each state.

    model <- function(){
  
  ## MODEL SPECIFICATION
  for(j in 1:nbird){
    for(i in 1:nobs[j]){
      alt[i,j] ~ dnorm(true_alt[i,j], tau.obs)
      log(true_alt[i,j]) <- log_true_alt[i,j]
      log_true_alt[i,j] ~ dnorm(mean.alt[i,j], tau[state[i,j]])
      mean.alt[i,j] <- alt1[state[i,j]] +  ind.re[j]
    }
  }
  
  for(i in 1:nstate){ tau[i] <- 1/(sig[i])  }
  
  # Random Effects:
  tau.re <- 1/sig.re
  for(j in 1:nbird) {  ind.re[j] ~ dnorm(0, tau.re)  }
  
  
  ## PRIORS
  for(i in 1:nstate) {
    alt1[i] ~ dnorm(0, 0.01)
    sig[i] ~ dunif(0, 200)
  }
  sig.re ~ dunif(0, 200)
  state ~ dunif(1,3)

  ## POSTERIOR PREDICTIVE DISTRIBUTIONS FOR EACH STATE
  for(s in 1:nstate){
  log_alt_pred[s] ~ dnorm(alt1[s], tau[s])
  log(alt_pred[s]) <- log_alt_pred[s]
  }

}

Thank you!!!

1

There are 1 best solutions below

1
On

It could be because in your priors you're trying to set a distribution for "alt1[i]" but in your model you've used "alt[i,j]".