Skip to content

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unmarkedTo

unmarkedTo is an in-development R package that converts unmarked package syntax for hierarchical models in ecology into inputs for other software packages. Currently the package supports translating a subset of unmarked model types to NIMBLE models for further analysis with MCMC. The package uses the nimbleMacros R package internally.

Here's a quick example showing how code for a single-season occupancy model in unmarked can be translated into the corresponding NIMBLE model with the unmarkedToNimble function:

library(unmarkedTo)

# Create some occupancy data 
y <- matrix(c(0,1,0,0,1,1), nrow=3, byrow=TRUE)
x <- rnorm(3)
umf <- unmarkedFrameOccu(y = y, siteCovs=data.frame(x=x))

# Build the model
nimble_model <- unmarkedToNimble(occu(~1~x, umf))

# Look at the resulting nimble code
nimble_model$getCode()
{
    for (i in 1:nsites) {
        logit(psi[i]) <- state_Intercept + state_x * x[i]
        for (j in 1:nobs) {
            logit(p[i, j]) <- det_Intercept
            y[i, j] ~ dbern(p[i, j] * z[i])
        }
        z[i] ~ dbern(psi[i])
    }
    state_Intercept ~ dlogis(0, 1)
    state_x ~ dlogis(0, 1)
    det_Intercept ~ dlogis(0, 1)
}

About

Translate unmarked models to other software packages

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages