Creates model code using the nimbleCode function.

get_unmarked(occ_specific = FALSE, hab_mask = FALSE, trapsClustered = FALSE)

Arguments

occ_specific

Logical. If FALSE, the encounter rate will not include an occasion-specific loop in the detection function; otherwise, the model will include a for loop for occasions (K) in the detection function. Default is FALSE.

hab_mask

A logical value indicating whether a habitat mask will be used. Default is FALSE.

trapsClustered

A logical value indicating if traps are clustered in arrays across the sampling area.

Value

Model code created from nimbleCode.

Details

This function provides templates for unmarked models that can be easily modified to include further model complexity such as covariates explaining detection probability. The models include habitat masking.

Author

Daniel Eacker

Examples

# get spatial count model with non-occasion-specific detection
# function, single scaling parameter, no habitat mask, and no clustering
unmarked_model = get_unmarked(occ_specific=FALSE,hab_mask = FALSE, 
                              trapsClustered = FALSE)

# inspect model
unmarked_model
#> {
#>     lam0 ~ dunif(0, lam0_upper)
#>     sigma ~ dunif(0, sigma_upper)
#>     psiu ~ dunif(0, 1)
#>     for (i in 1:m) {
#>         zu[i] ~ dbern(psiu)
#>         su[i, 1] ~ dunif(x_lower, x_upper)
#>         su[i, 2] ~ dunif(y_lower, y_upper)
#>         distu[i, 1:J] <- sqrt((su[i, 1] - X[1:J, 1])^2 + (su[i, 
#>             2] - X[1:J, 2])^2)
#>         lamu[i, 1:J] <- lam0 * exp(-distu[i, 1:J]^2/(2 * sigma^2)) * 
#>             zu[i]
#>     }
#>     for (j in 1:J) {
#>         bigLambda[j] <- sum(lamu[1:m, j])
#>         for (k in 1:K) {
#>             n[j, k] ~ dpois(bigLambda[j])
#>         }
#>     }
#>     N <- sum(zu[1:m])
#>     D <- N/A
#> }