Random index

Help
Richard
2014-06-05
2014-06-12
  • Richard
    Richard
    2014-06-05

    Hi,

    I need an index to be a random variable, but both JAGS and OpenBUGS give me error messages when I attempt this. An example illustrating what I would like to do is pasted below.

    The real problem I'm working on is more complex than this example. It involves data augmentation such that many of the y variables are augmented, and the "correct" augmented data depends on which location the individual is assigned to.

    If this isn't possible, could someone suggest a workaround?

    Thanks,
    Richard

    R code

    jy <- matrix(0:1, 2, 10)
    jd <- list(y=jy, pi=rep(1/10, 10))
    ji <- list(location=1:10)
    jm <- jags.model("randomIndex.jag", data=jd, inits=ji)

    "randomIndex.jag"

    model{
    p ~ dbeta(1,1)
    for(j in 1:10) {
    location[j] ~ dcat(pi[])
    test[j] <- (location[j]<6)+1
    y[test[j],j] ~ dbern(p)
    }
    }

     
  • Richard
    Richard
    2014-06-05

    I figured out a solution that doesn't involve a random index. Sorry for the noise.

     
  • As penance, or to satisfy our curiosity, could you post your particular solution?

    http://xkcd.com/979/

     
  • Richard
    Richard
    2014-06-12

    Hi Krzysztof,

    The solution involved setting all of the augmented individuals' data to "not observed", then using a logical test to fix detection probability to 0 for individuals that were assigned to sites that were not surveyed on a particular occasion. I can send you more info off-list if you're still curious. The model is an extension of this one:

    http://arxiv.org/pdf/1211.5706.pdf