# 5 Dispersal

WORK IN PROGRESS.

## 5.1 Introduction

Blabla.

knitr::include_graphics("images/arnason1973.png")
knitr::include_graphics("images/schwarz1993.png")
knitr::include_graphics("images/deadpool.gif")

knitr::include_graphics("images/nichols.png")

## 5.2 Wintering site fidelity in Canada Geese

### 5.2.1 3 sites Carolinas, Chesapeake, Mid-Atlantic,

with 21277 banded geese, data kindly provided by Jay Hestbeck (Hestbeck et al. 1991)

year_1984 year_1985 year_1986 year_1987 year_1988 year_1989
0 2 2 0 0 0
0 0 0 0 0 2
0 0 0 1 0 0
0 0 2 0 0 0
0 3 0 0 3 2
0 0 0 2 0 0
2 2 0 2 3 2
0 0 0 0 2 2
0 0 0 1 0 0
0 2 0 0 0 0
0 2 0 0 3 2
0 0 3 0 0 0
0 0 2 0 0 0
2 0 0 0 0 0
0 0 0 0 1 0
0 0 0 1 0 0
3 0 0 0 0 0
0 0 0 0 3 1
0 0 2 0 2 0
0 0 0 2 0 0
0 0 0 0 2 2
0 1 0 0 0 0
0 3 0 0 0 0
0 0 0 0 2 0
0 0 0 0 2 0
0 0 0 2 0 0
0 0 1 0 0 0
0 0 0 2 0 3
0 0 3 0 0 0
0 3 3 0 3 3
0 0 0 1 0 0
0 0 0 1 1 0
0 0 2 2 0 2
0 0 0 3 3 0
0 0 0 2 0 0
2 0 0 0 0 0
0 1 0 0 0 0
0 0 0 1 0 0
0 0 2 2 0 0
0 2 0 0 0 0
3 0 0 0 0 0
0 2 0 0 0 0
0 0 3 2 0 0
0 0 0 0 2 0
0 2 0 0 0 0
0 0 1 1 0 0
0 2 0 0 0 0
0 2 2 2 0 0
0 1 0 0 0 0
2 2 0 0 0 0
2 0 0 0 0 0
0 0 0 0 1 0
0 0 0 0 1 1
0 2 0 0 0 0
0 0 2 2 0 2
0 0 2 0 0 0
0 0 0 0 3 0
0 1 0 2 0 0
0 0 2 2 0 0
0 0 2 0 2 0
0 0 0 2 0 0
0 3 0 0 0 0
0 0 0 2 0 0
0 0 0 1 0 0
0 0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
0 2 0 0 0 0
0 0 0 0 0 1
0 2 3 3 0 0
2 2 2 0 2 0
2 0 0 0 0 0
0 0 3 0 0 0
0 2 0 0 0 0
0 0 1 0 2 1
0 0 0 1 0 0

(large areas along East coast of US)

### 5.2.2 Biological inference

Observations and states are closely related, but not entirely.

### 5.2.3 The model construction: How we should think.

Generative model. States generate observations.

### 5.2.7 HMM model for dispersal with 2 sites (drop Carolinas)

Transition matrix

$\begin{matrix} & \\ \mathbf{\Gamma} = \left ( \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right . \end{matrix} \hspace{-1.2em} \begin{matrix} z_{t}=A & z_{t}=B & z_{t}=D \\ \hdashline \phi_A (1-\psi_{AB}) & \phi_A \psi_{AB} & 1 - \phi_A\\ \phi_B \psi_{BA} & \phi_B (1-\psi_{BA}) & 1 - \phi_B\\ 0 & 0 & 1 \end{matrix} \hspace{-0.2em} \begin{matrix} & \\ \left . \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right ) \begin{matrix} z_{t-1}=A \\ z_{t-1}=B \\ z_{t-1}=D \end{matrix} \end{matrix}$

### 5.2.8 HMM model for dispersal with 2 sites (drop Carolinas)

Observation matrix

$\begin{matrix} & \\ \mathbf{\Omega} = \left ( \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right . \end{matrix} \hspace{-1.2em} \begin{matrix} y_t=0 & y_t=1 & y_t=2 \\ \hdashline 1 - p_A & p_A & 0\\ 1 - p_B & 0 & p_B\\ 1 & 0 & 0 \end{matrix} \hspace{-0.2em} \begin{matrix} & \\ \left . \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right ) \begin{matrix} z_{t}=A \\ z_{t}=B \\ z_{t}=D \end{matrix} \end{matrix}$

### 5.2.9 HMM model for dispersal with 2 sites (drop Carolinas)

Observation matrix

$\begin{matrix} & \\ \mathbf{\Omega} = \left ( \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right . \end{matrix} \hspace{-1.2em} \begin{matrix} y_t=0 & y_t=1 & y_t=2 \\ \hdashline 1 - p_A & p_A & 0\\ 1 - p_B & 0 & p_B\\ 1 & 0 & 0 \end{matrix} \hspace{-0.2em} \begin{matrix} & \\ \left . \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right ) \begin{matrix} z_{t}=A \\ z_{t}=B \\ z_{t}=D \end{matrix} \end{matrix}$

Note: You may code non-detections as $$y_t = 2$$, and the first column in the observation matrix should go last.

Quick answer about the -1 and the important issue of coding states and obs. I did this on purpose, to have folks think about the difference between observations and states (non-detection obs should not be confused with state for dead). This becomes even more crucial when we get to multievent models where several observations may be generated by a single state. I get the intuition argument perfectly, but I’d like them to fight against it at first, then once they’re comfortable with the difference, they may code obs/states as they see fit. Let’s see how it goes. I agree that we should mention that during the multistate lecture, in the spirit of « you’re free to code states and jobs the way you like ». I’ll add something.

### 5.2.10 Our model $$(\phi_A, \phi_B, \psi_{AB}, \psi_{BA}, p_A, p_B)$$

multisite <- nimbleCode({
# -------------------------------------------------
# Parameters:
# phiA: survival probability site A
# phiB: survival probability site B
# psiAB: movement probability from site A to site B
# psiBA: movement probability from site B to site A
# pA: recapture probability site A
# pB: recapture probability site B
# -------------------------------------------------
# States (z):
# 1 alive at A
# 2 alive at B
# Observations (y):
# 1 not seen
# 2 seen at A
# 3 seen at B
# -------------------------------------------------
...

### 5.2.11 Our model $$(\phi_A, \phi_B, \psi_{AB}, \psi_{BA}, p_A, p_B)$$

multisite <- nimbleCode({
...
# Priors
phiA ~ dunif(0, 1)
phiB ~ dunif(0, 1)
psiAB ~ dunif(0, 1)
psiBA ~ dunif(0, 1)
pA ~ dunif(0, 1)
pB ~ dunif(0, 1)
...

### 5.2.12 Our model $$(\phi_A, \phi_B, \psi_{AB}, \psi_{BA}, p_A, p_B)$$

multisite <- nimbleCode({
...
# initial state probabilities
delta[1] <- piA          # Pr(alive in A t = 1)
delta[2] <- 1 - piA      # Pr(alive in B t = 1)
delta[3] <- 0            # Pr(dead t = 1) = 0
...

Actually, initial state is known exactly. It is alive at site of initial capture, and $$\pi_A$$ is just the proportion of individuals first captured in site A, no need to estimate it.

Instead of z[i,first[i]] ~ dcat(delta[1:3]), use z[i,first[i]] <- y[i,first[i]]-1 instead in the likelihood.

Same trick applies to CJS models.

### 5.2.13 Our model $$(\phi_A, \phi_B, \psi_{AB}, \psi_{BA}, p_A, p_B)$$

multisite <- nimbleCode({
...
# probabilities of state z(t+1) given z(t)
# (read as gamma[z(t),z(t+1)] = gamma[fromState,toState])

gamma[1,1] <- phiA * (1 - psiAB)
gamma[1,2] <- phiA * psiAB
gamma[1,3] <- 1 - phiA
gamma[2,1] <- phiB * psiBA
gamma[2,2] <- phiB * (1 - psiBA)
gamma[2,3] <- 1 - phiB
gamma[3,1] <- 0
gamma[3,2] <- 0
gamma[3,3] <- 1
...

### 5.2.14 Our model $$(\phi_A, \phi_B, \psi_{AB}, \psi_{BA}, p_A, p_B)$$

multisite <- nimbleCode({
...
# probabilities of y(t) given z(t)
# (read as omega[y(t),z(t)] = omega[Observation,State])

omega[1,1] <- 1 - pA     # Pr(alive A t -> non-detected t)
omega[1,2] <- pA         # Pr(alive A t -> detected A t)
omega[1,3] <- 0          # Pr(alive A t -> detected B t)
omega[2,1] <- 1 - pB     # Pr(alive B t -> non-detected t)
omega[2,2] <- 0          # Pr(alive B t -> detected A t)
omega[2,3] <- pB         # Pr(alive B t -> detected B t)
omega[3,1] <- 1          # Pr(dead t -> non-detected t)
omega[3,2] <- 0          # Pr(dead t -> detected A t)
omega[3,3] <- 0          # Pr(dead t -> detected B t)
...

### 5.2.15 Our model $$(\phi_A, \phi_B, \psi_{AB}, \psi_{BA}, p_A, p_B)$$

multisite <- nimbleCode({
...
# likelihood
for (i in 1:N){
# latent state at first capture
z[i,first[i]] <- y[i,first[i]] - 1
for (t in (first[i]+1):K){
# z(t) given z(t-1)
z[i,t] ~ dcat(gamma[z[i,t-1],1:3])
# y(t) given z(t)
y[i,t] ~ dcat(omega[z[i,t],1:3])
}
}
})
##       mean   sd 2.5%  50% 97.5% Rhat n.eff
## pA    0.53 0.09 0.36 0.52  0.73 1.04   122
## pB    0.40 0.04 0.32 0.40  0.48 1.07   165
## phiA  0.60 0.05 0.50 0.60  0.71 1.01   195
## phiB  0.69 0.04 0.62 0.69  0.76 1.04   199
## psiAB 0.27 0.06 0.16 0.26  0.40 1.04   244
## psiBA 0.07 0.02 0.04 0.07  0.12 1.03   360

## 5.3 What if there are three sites?

The transition probabilities still need to be between 0 and 1.

Another constraint is that the sum of three probabilities of departure from a given site should be one.

Two methods to fulfill both constraints. Dirichlet prior and multinomial logit link.

Dirichlet prior with parameter alpha

### 5.3.1 Nimble implementation of the Dirichlet prior

multisite <- nimbleCode({
...
# transitions: Dirichlet priors
psiA[1:3] ~ ddirch(alpha[1:3]) # psiAA, psiAB, psiAC
psiB[1:3] ~ ddirch(alpha[1:3]) # psiBA, psiBB, psiCC
psiC[1:3] ~ ddirch(alpha[1:3]) # psiCA, psiCB, psiCC
...

### 5.3.2 Nimble implementation of the Dirichlet prior

multisite <- nimbleCode({
...
# probabilities of state z(t+1) given z(t)
gamma[1,1] <- phiA * psiA[1]
gamma[1,2] <- phiA * psiA[2]
gamma[1,3] <- phiA * psiA[3]
gamma[1,4] <- 1 - phiA
gamma[2,1] <- phiB * psiB[1]
gamma[2,2] <- phiB * psiB[2]
gamma[2,3] <- phiB * psiB[3]
gamma[2,4] <- 1 - phiB
gamma[3,1] <- phiC * psiC[1]
gamma[3,2] <- phiC * psiC[2]
gamma[3,3] <- phiC * psiC[3]
gamma[3,4] <- 1 - phiC
gamma[4,1] <- 0
gamma[4,2] <- 0
gamma[4,3] <- 0
gamma[4,4] <- 1
...
##         mean   sd 2.5%  50% 97.5% Rhat n.eff
## pA      0.50 0.09 0.34 0.50  0.70 1.00   153
## pB      0.47 0.05 0.38 0.46  0.58 1.01   152
## pC      0.24 0.06 0.14 0.23  0.37 1.01   117
## phiA    0.61 0.05 0.50 0.61  0.71 1.00   230
## phiB    0.70 0.04 0.62 0.70  0.77 1.04   183
## phiC    0.77 0.07 0.64 0.77  0.92 1.07   104
## psiA[1] 0.75 0.05 0.63 0.75  0.84 1.01   463
## psiA[2] 0.23 0.05 0.14 0.22  0.34 1.01   441
## psiA[3] 0.02 0.02 0.00 0.02  0.08 1.03   201
## psiB[1] 0.07 0.02 0.04 0.07  0.12 1.00   275
## psiB[2] 0.83 0.04 0.72 0.83  0.90 1.04   129
## psiB[3] 0.10 0.04 0.04 0.09  0.18 1.06   129
## psiC[1] 0.02 0.01 0.00 0.02  0.06 1.00   624
## psiC[2] 0.21 0.05 0.12 0.21  0.33 1.02   420
## psiC[3] 0.77 0.06 0.64 0.77  0.86 1.02   419

### 5.3.3 Multinomial logit

Say we have $$P$$ sites or states.

Specify a normal prior distribution for $$P-1$$ transition parameters $$\alpha_j$$. These probabilities are on the multinomial logit scale, possibly function of covariates.

To back-transform these parameters, we use:

$\beta_j = \displaystyle{\frac{\exp(\alpha_j)}{1+\displaystyle{\sum_{p=1}^P{\exp(\alpha_p)}}}}, j = 1,\ldots,P-1$

This ensures that all $$\beta_j$$ are between 0 and 1, and their sum is 1.

Last parameter is calculated as the complement $$\beta_P = 1 - \displaystyle{\sum_{j=1}^{P-1}{\exp(\beta_j)}}$$

### 5.3.4 Nimble implementation of the Dirichlet prior

multisite <- nimbleCode({
...
# transitions: multinomial logit
# normal priors on logit of all but one transition probs
for (i in 1:2){
lpsiA[i] ~ dnorm(0, sd = 1000)
lpsiB[i] ~ dnorm(0, sd = 1000)
lpsiC[i] ~ dnorm(0, sd = 1000)
}
# constrain the transitions such that their sum is < 1
for (i in 1:2){
psiA[i] <- exp(lpsiA[i]) / (1 + exp(lpsiA[1]) + exp(lpsiA[2]))
psiB[i] <- exp(lpsiB[i]) / (1 + exp(lpsiB[1]) + exp(lpsiB[2]))
psiC[i] <- exp(lpsiC[i]) / (1 + exp(lpsiC[1]) + exp(lpsiC[2]))
}
# last transition probability
psiA[3] <- 1 - psiA[1] - psiA[2]
psiB[3] <- 1 - psiB[1] - psiB[2]
psiC[3] <- 1 - psiC[1] - psiC[2]
...

### 5.3.5 Nimble implementation of the Dirichlet prior

multisite <- nimbleCode({
...
# probabilities of state z(t+1) given z(t)
gamma[1,1] <- phiA * psiA[1]
gamma[1,2] <- phiA * psiA[2]
gamma[1,3] <- phiA * psiA[3]
gamma[1,4] <- 1 - phiA
gamma[2,1] <- phiB * psiB[1]
gamma[2,2] <- phiB * psiB[2]
gamma[2,3] <- phiB * psiB[3]
gamma[2,4] <- 1 - phiB
gamma[3,1] <- phiC * psiC[1]
gamma[3,2] <- phiC * psiC[2]
gamma[3,3] <- phiC * psiC[3]
gamma[3,4] <- 1 - phiC
gamma[4,1] <- 0
gamma[4,2] <- 0
gamma[4,3] <- 0
gamma[4,4] <- 1
...
##         mean   sd 2.5%  50% 97.5% Rhat n.eff
## pA      0.52 0.08 0.36 0.52  0.69 1.02   154
## pB      0.45 0.05 0.35 0.44  0.55 1.10   129
## pC      0.26 0.06 0.15 0.25  0.39 1.01    94
## phiA    0.60 0.05 0.50 0.60  0.71 1.01   244
## phiB    0.70 0.04 0.63 0.70  0.77 1.11   168
## phiC    0.76 0.07 0.63 0.76  0.88 1.03   126
## psiA[1] 0.76 0.05 0.64 0.76  0.85 1.02   477
## psiA[2] 0.24 0.05 0.15 0.24  0.36 1.01   486
## psiA[3] 0.00 0.00 0.00 0.00  0.00 1.35    47
## psiB[1] 0.07 0.02 0.04 0.06  0.11 1.03   394
## psiB[2] 0.85 0.04 0.77 0.86  0.91 1.04   133
## psiB[3] 0.08 0.03 0.04 0.08  0.16 1.01    79
## psiC[1] 0.01 0.01 0.00 0.01  0.04 1.00   514
## psiC[2] 0.21 0.05 0.12 0.21  0.33 1.00   299
## psiC[3] 0.78 0.06 0.65 0.78  0.88 1.00   270

## 5.5 Examples of multistate models

• Epidemiological or disease states: sick/healthy, uninfected/infected/recovered.

• Morphological states: small/medium/big, light/medium/heavy.

• Breeding states: e.g. breeder/non-breeder, failed breeder, first-time breeder.

• Social states: e.g. solitary/group-living, subordinate/dominant.

• Death states: e.g. alive, dead from harvest, dead from natural causes.

States = individual, time-specific categorical covariates.

knitr::include_graphics("images/sooty.jpg")

## 5.6 Sooty shearwaters and life-history tradeoffs

We consider data collected between 1940 and 1957 by Lance Richdale on Sooty shearwaters (aka titis).

These data were reanalyzed with multistate models by Scofield et al. (2001) who kindly provided us with the data.

Following the way the data were collected, four states were originally considered: Alive breeder; Accompanied by another bird in a burrow; Alone in a burrow; On the surface; Dead.

## 5.7 Sooty shearwaters and life-history tradeoffs

Because of numerical issues, we pooled all alive states but breeder together in a non-breeder state (NB) that includes:

• failed breeders (birds that had bred previously – skip reproduction or divorce) and pre-breeders (birds that had yet to breed).

• Note that because burrows were not checked before hatching, some birds in the category NB might have already failed.

• We therefore regard those birds in the B state as successful breeders, and those in the NB state as nonbreeders plus prebreeders and failed breeders.

Observations are non-detections, and detections as breeder and non-breeder

Does breeding affect survival? Does breeding in current year affect breeding next year?

year_1942 year_1943 year_1944 year_1949 year_1952 year_1953 year_1956
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0 0 1
0 0 0 0 0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 0 2 0
1 2 2 2 2 2 0
2 0 0 0 0 0 0
2 0 0 0 0 0 0
2 0 0 0 0 0 0
2 0 0 0 0 0 0
2 0 0 0 0 0 0
2 0 0 0 0 0 0
2 0 0 0 0 0 0
2 0 0 0 0 0 0
2 0 0 0 0 0 0
2 0 0 0 2 0 0
2 0 0 2 0 2 1
2 0 0 2 0 2 1
2 0 0 2 2 0 0
2 0 2 0 0 0 0
2 0 2 0 0 0 0
2 0 2 0 0 2 1
2 0 2 0 2 2 0
2 0 2 2 0 0 0
2 0 2 2 0 0 0
2 1 0 2 2 2 0
2 1 2 2 0 2 1
2 2 0 0 0 0 0
2 2 0 0 0 0 0
2 2 0 0 0 0 0
2 2 0 0 0 0 0
2 2 0 2 0 0 0
2 2 2 0 0 0 0
2 2 2 0 0 0 0
2 2 2 0 2 2 0

### 5.7.1 HMM model for transition between states

Transition matrix

$\begin{matrix} & \\ \mathbf{\Gamma} = \left ( \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right . \end{matrix} \hspace{-1.2em} \begin{matrix} z_t=B & z_t=NB & z_t=D \\ \hdashline \phi_B (1-\psi_{BNB}) & \phi_B \psi_{BNB} & 1 - \phi_B\\ \phi_{NB} \psi_{NBB} & \phi_{NB} (1-\psi_{NBB}) & 1 - \phi_{NB}\\ 0 & 0 & 1 \end{matrix} \hspace{-0.2em} \begin{matrix} & \\ \left . \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right ) \begin{matrix} z_{t-1}=B \\ z_{t-1}=NB \\ z_{t-1}=D \end{matrix} \end{matrix}$

• Costs or reproduction would reflect in future reproduction $$\psi_{BB} = 1 - \psi_{BNB} < \psi_{NBB}$$ or survival $$\phi_B < \phi_{NB}$$.

### 5.7.2 HMM model for transition between states

Observation matrix

$\begin{matrix} & \\ \mathbf{\Omega} = \left ( \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right . \end{matrix} \hspace{-1.2em} \begin{matrix} y_t=0 & y_t=1 & y_t=2 \\ \hdashline 1 - p_B & p_B & 0\\ 1 - p_{NB} & 0 & p_{NB}\\ 1 & 0 & 0 \end{matrix} \hspace{-0.2em} \begin{matrix} & \\ \left . \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right ) \begin{matrix} z_{t}=B \\ z_{t}=NB \\ z_{t}=D \end{matrix} \end{matrix}$

### 5.7.3 Our model $$(\phi_{NB}, \phi_B, \psi_{NBB}, \psi_{BNB}, p_{NB}, p_B)$$

multistate <- nimbleCode({
# -------------------------------------------------
# Parameters:
# phiB: survival probability state B
# phiNB: survival probability state NB
# psiBNB: transition probability from B to NB
# psiNBB: transition probability from NB to B
# pB: recapture probability B
# pNB: recapture probability NB
# -------------------------------------------------
# States (z):
# 1 alive B
# 2 alive NB
# Observations (y):
# 1 not seen
# 2 seen as B
# 3 seen as NB
# -------------------------------------------------
...

### 5.7.4 Our model $$(\phi_{NB}, \phi_B, \psi_{NBB}, \psi_{BNB}, p_{NB}, p_B)$$

multistate <- nimbleCode({
...
# Priors
phiB ~ dunif(0, 1)
phiNB ~ dunif(0, 1)
psiBNB ~ dunif(0, 1)
psiNBB ~ dunif(0, 1)
pB ~ dunif(0, 1)
pNB ~ dunif(0, 1)
...

### 5.7.5 Our model $$(\phi_{NB}, \phi_B, \psi_{NBB}, \psi_{BNB}, p_{NB}, p_B)$$

multistate <- nimbleCode({
...
# probabilities of state z(t+1) given z(t)
gamma[1,1] <- phiB * (1 - psiBNB)
gamma[1,2] <- phiB * psiBNB
gamma[1,3] <- 1 - phiB
gamma[2,1] <- phiNB * psiNBB
gamma[2,2] <- phiNB * (1 - psiNBB)
gamma[2,3] <- 1 - phiNB
gamma[3,1] <- 0
gamma[3,2] <- 0
gamma[3,3] <- 1
...

### 5.7.6 Our model $$(\phi_{NB}, \phi_B, \psi_{NBB}, \psi_{BNB}, p_{NB}, p_B)$$

multistate <- nimbleCode({
...
# probabilities of y(t) given z(t)
omega[1,1] <- 1 - pB    # Pr(alive B t -> non-detected t)
omega[1,2] <- pB        # Pr(alive B t -> detected B t)
omega[1,3] <- 0         # Pr(alive B t -> detected NB t)
omega[2,1] <- 1 - pNB   # Pr(alive NB t -> non-detected t)
omega[2,2] <- 0         # Pr(alive NB t -> detected B t)
omega[2,3] <- pNB       # Pr(alive NB t -> detected NB t)
omega[3,1] <- 1         # Pr(dead t -> non-detected t)
omega[3,2] <- 0         # Pr(dead t -> detected N t)
omega[3,3] <- 0         # Pr(dead t -> detected NB t)
...

### 5.7.7 Our model $$(\phi_{NB}, \phi_B, \psi_{NBB}, \psi_{BNB}, p_{NB}, p_B)$$

multistate <- nimbleCode({
...
# likelihood
for (i in 1:N){
# latent state at first capture
z[i,first[i]] <- y[i,first[i]] - 1
for (t in (first[i]+1):K){
# z(t) given z(t-1)
z[i,t] ~ dcat(gamma[z[i,t-1],1:3])
# y(t) given z(t)
y[i,t] ~ dcat(omega[z[i,t],1:3])
}
}
})
##        mean   sd 2.5%  50% 97.5% Rhat n.eff
## pB     0.60 0.03 0.54 0.59  0.66 1.00   202
## pNB    0.57 0.03 0.51 0.57  0.62 1.01   281
## phiB   0.80 0.02 0.77 0.80  0.83 1.01   313
## phiNB  0.85 0.02 0.82 0.85  0.88 1.00   404
## psiBNB 0.25 0.02 0.21 0.25  0.30 1.00   434
## psiNBB 0.24 0.02 0.20 0.24  0.29 1.03   478

## 5.8 Multistate models are very flexible

Temporary emigration

Combination of life and dead encounters

Transition matrix:

$\begin{matrix} & \\ \mathbf{\Gamma} = \left ( \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \\ 12 \\ 12 \end{matrix} } \right . \end{matrix} \hspace{-1.2em} \begin{matrix} z_t=J & z_t=1yNB & z_t=2yNB & z_t=B & z_t=D \\ \hdashline 0 & \phi_1 (1-\alpha_1) & 0 & \phi_1 \alpha_1 & 1 - \phi_1\\ 0 & 0 & \phi_2 (1-\alpha_2) & \phi_2 \alpha_2 & 1 - \phi_2\\ 0 & 0 & 0 & \phi_3 & 1 - \phi_3\\ 0 & 0 & 0 & \phi_B & 1 - \phi_B\\ 0 & 0 & 0 & 0 & 1 \end{matrix} \hspace{-0.2em} \begin{matrix} & \\ \left . \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \\ 12 \\ 12 \end{matrix} } \right ) \begin{matrix} z_{t-1} = J \\ z_{t-1} = 1yNB \\ z_{t-1} = 2yNB \\ z_{t-1} = B \\ z_{t-1} = D \end{matrix} \end{matrix}$

First-year and second-year individuals breed with probabilities $$\alpha_1$$ and $$\alpha_2$$.

Then, everybody breeds from age 3.

Observation matrix:

$\begin{matrix} & \\ \mathbf{\Omega} = \left ( \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \\ 12 \\12 \end{matrix} } \right . \end{matrix} \hspace{-1.2em} \begin{matrix} y_t = 0 & y_t = 1 & y_t = 2 & y_t = 3\\ \hdashline 1 & 0 & 0 & 0\\ 1 - p_1 & p_1 & 0 & 0\\ 1 - p_2 & 0 & p_2 & 0\\ 1 - p_3 & 0 & 0 & p_3\\ 1 & 0 & 0 & 0 \end{matrix} \hspace{-0.2em} \begin{matrix} & \\ \left . \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \\ 12 \\12 \end{matrix} } \right ) \begin{matrix} z_t = J \\ z_t = 1yNB \\ z_t = 2yNB \\ z_t = B \\ z_t = D \end{matrix} \end{matrix}$

Juveniles are never detected.

## 5.9 Temporary emigration

Transition matrix:

$\begin{matrix} & \\ \mathbf{\Gamma} = \left ( \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right . \end{matrix} \hspace{-1.2em} \begin{matrix} z_t=\text{in} & z_t=\text{out} & z_t=\text{D} \\ \hdashline \phi (1-\psi_{\text{in} \rightarrow \text{out}}) & \phi \psi_{\text{in} \rightarrow \text{out}} & 1 - \phi\\ \phi \psi_{\text{out} \rightarrow \text{in}} & \phi (1-\psi_{\text{out} \rightarrow \text{in}}) & 1 - \phi\\ 0 & 0 & 1 \end{matrix} \hspace{-0.2em} \begin{matrix} & \\ \left . \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right ) \begin{matrix} z_{t-1}=\text{in} \\ z_{t-1}=\text{out} \\ z_{t-1}=\text{D} \end{matrix} \end{matrix}$

Observation matrix:

$\begin{matrix} & \\ \mathbf{\Omega} = \left ( \vphantom{ \begin{matrix} 12 \\ 12 \end{matrix} } \right . \end{matrix} \hspace{-1.2em} \begin{matrix} y_t=0 & y_t=1 \\ \hdashline 1 - p & p\\ 1 & 0\\ 1 & 0 \end{matrix} \hspace{-0.2em} \begin{matrix} & \\ \left . \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right ) \begin{matrix} z_{t}=\text{in} \\ z_{t}=\text{out} \\ z_{t}=\text{D} \end{matrix} \end{matrix}$

### 5.9.1 Combination of life and dead encounters

Transition matrix

$\begin{matrix} & \\ \mathbf{\Gamma} = \left ( \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right . \end{matrix} \hspace{-1.2em} \begin{matrix} z_t=A & z_t=JD & z_t=D \\ \hdashline s & 1-s & 0\\ 0 & 0 & 1\\ 0 & 0 & 1 \end{matrix} \hspace{-0.2em} \begin{matrix} & \\ \left . \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right ) \begin{matrix} z_{t-1}=\text{alive} \\ z_{t-1}=\text{just dead} \\ z_{t-1}=\text{dead for good} \end{matrix} \end{matrix}$

Observation matrix

$\begin{matrix} & \\ \mathbf{\Omega} = \left ( \vphantom{ \begin{matrix} 12 \\ 12 \\ 12\end{matrix} } \right . \end{matrix} \hspace{-1.2em} \begin{matrix} y_t=0 & y_t=1 & y_t=2 \\ \hdashline 1 - p & 0 & p\\ 1 - r & r & 0\\ 1 & 0 & 0 \end{matrix} \hspace{-0.2em} \begin{matrix} & \\ \left . \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \end{matrix} } \right ) \begin{matrix} z_{t}=A \\ z_{t}=JD \\ z_{t}=D \end{matrix} \end{matrix}$

## 5.10 Issue of local minima

Simulated data: 2 sites or states, and 7 occasions, Survival $$\phi = 1$$, detection $$p = 0.6$$, Transition $$\psi_{12} = 0.6$$, Transition $$\psi_{21} = 0.85$$.

Courtesy of Jérôme Dupuis, used in Gimenez et al. (2005).

### 5.10.1 Data

V1 V2 V3 V4 V5 V6 V7
2 0 2 1 2 0 2
2 0 2 1 2 0 2
2 0 2 1 2 0 2
2 0 2 1 2 0 2
1 1 1 0 1 0 1
1 1 1 0 1 0 1
1 1 1 0 1 0 1
1 1 1 0 1 0 1
2 0 2 0 2 0 1
2 0 2 0 2 0 1
2 0 2 0 2 0 1
2 0 2 0 2 0 1
1 0 1 0 1 0 1
1 0 1 0 1 0 1
1 0 1 0 1 0 1
1 0 1 0 1 0 1
2 0 2 0 2 0 2
2 0 2 0 2 0 2
2 0 2 0 2 0 2
2 0 2 0 2 0 2
1 0 1 0 1 0 2
1 0 1 0 1 0 2
1 0 1 0 1 0 2
1 0 1 0 1 0 2
2 2 0 1 0 2 1
2 2 0 1 0 2 1
2 2 0 1 0 2 1
2 2 0 1 0 2 1
2 1 0 2 0 1 1
2 1 0 2 0 1 1
2 1 0 2 0 1 1
2 1 0 2 0 1 1
knitr::include_graphics("images/multistate_local_minimav2_Page_05.png")
knitr::include_graphics("images/multistate_local_minimav2_Page_06.png")
knitr::include_graphics("images/multistate_local_minimav2_Page_07.png")

• Blabla.

• Blabla.