## model "Double with covatiates" used in: ## Extracting More out of Relocation Data: Building Movement Models as Mixtures of Random Walks ## Juan Manuel Morales, Daniel T. Haydon, Jacqui Frair, Kent E. Holsinger and John M. Fryxell ## contact juan.morales@uconn.edu model{ ## priors b[1] ~ dgamma(0.01,0.01) ## shape parameter for slow movement b[2] ~ dgamma(0.01,0.01) ## shape parameter for fast movement a[2] ~ dgamma(0.01, 0.01) ## scale parameter for fast movement eps ~ dnorm(0.0, 0.01)I(0.0,) ## a nonnegative variate a[1] <- a[2] + eps ## scale parameter for slow movement rho[1] ~ dunif(0,1) ## mean cosine of turns for slow movement rho[2] ~ dunif(0,1) ## mean cosine of turns for slow movement mu[1] ~ dunif(-3.14159265359, 3.14159265359) ## mean direction of turns for slow movement mu[2] ~ dunif(-3.14159265359, 3.14159265359) ## mean direction of turns for fast movement ## priors for habitat types for (i in 1:10) { mu.phi[i] ~ dnorm(0.0, 0.01) } Pi <- 3.14159265359 ## define pi for (t in 1:npts) { ## movement state is related to current habitat type mu.type[t] <- mu.phi[typ[t]] ## typ is a variable that indicates habitat type at current location logit.nu[t] ~ dnorm(mu.type[t], 0.01) nu_h[t] <- exp(logit.nu[t])/(1 + exp(logit.nu[t])) ## probability of being in movement type 1 nu[t,1] <- nu_h[t] nu[t,2] <- 1 - nu_h[t] idx[t] ~ dcat(nu[t,]) ## idx is the latent variable and the parameter index ## likelihood for steps l[t] ~ dweib(b[idx[t]], a[idx[t]]) # Weibull distriution for step length ## likelihood for turns. ## use the “ones” trick (see WinBUGS manual) to sample from the Wrapped Cauchy distribution ones[t] <- 1 ones[t] ~ dbern(wC[t]) ## below is the pdf for Wrapped Cauchy distribution, divided by 500 (arbitrary) to ensure that wC[t] will be less than one wC[t] <- ( 1/(2*Pi)*(1-rho[idx[t]]*rho[idx[t]])/(1+rho[idx[t]]*rho[idx[t]]-2*rho[idx[t]]*cos(theta[t]-mu[idx[t]t])) )/500 } }