## define model code
code <- nimbleCode({
for(i in 1:N) {
s[i, 1] ~ dunif(0, 100)
s[i, 2] ~ dunif(0, 100)
OK[i] ~ dHabitatMask( s = s[i,1:2],
xmax = 100,
xmin = 0,
ymax = 100,
ymin = 0,
habitatMask = habitatMask[1:100,1:100])
}
})
N <- 20
habitatMask <- matrix(rbinom(10000,1,0.75), nrow = 100)
constants <- list(N = N, habitatMask = habitatMask)
data <- list(OK = rep(1, N))
inits <- list(s = array(runif(2*N, 0, 100), c(N,2)))
## create NIMBLE model object
Rmodel <- nimbleModel(code, constants, data, inits)
## use model object for MCMC, etc.
Run the code above in your browser using DataLab