## model "Triple switch" 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 ## shape parameters for step length b[1] ~ dgamma(0.01,0.01) b[2] ~ dgamma(0.01,0.01) b[3] ~ dgamma(0.01,0.01) eps1 ~ dnorm(0.0, 0.01)I(0.0,) eps2 ~ dnorm(0.0, 0.01)I(0.0,) ## scale parameters for step length a[3] ~ dgamma(0.01, 0.01) a[2] <- a[3] + eps1 a[1] <- a[2] + eps2 ## mean cosine for turns rho[1] ~ dunif(0,1) rho[2] ~ dunif(0,1) rho[3] ~ dunif(0,1) ## mean direction for turns mu[1] ~ dunif(-3.14159265359, 3.14159265359) mu[2] ~ dunif(-3.14159265359, 3.14159265359) mu[3] ~ dunif(-3.14159265359, 3.14159265359) ## priors for the probability of switching from anything to 1 qq[1] ~ dunif(0,1) qq[2] ~ dunif(0,1) qq[3] ~ dunif(0,1) q[1] ~ dunif(0,1) q[2] ~ dunif(0,1) q[3] ~ dunif(0,1) ## asign state for first observation idx[1] ~ dcat(phi[]) Pi <- 3.14159265359 ## define pi for (t in 2:npts) { nu[t,1] <- q[idx[t-1]] nu[t,2] <- (1 -q [idx[t-1]] ) * qq[idx[t-1]] nu[t,3] <- (1 -q [idx[t-1]] ) * (1-qq[idx[t-1]] ) 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 } }