# Track Lizard Movement with a Capture-Recapture Model

This example illustrates using a hidden Markov model to reconstruct the most probable lizard migration pattern, as well as estimate a lizard's expected lifespan from a sequence of incomplete trapping records.

Lizards move between three zones represented by states 2, 3, 4. When they die they transition into state 1. Each lizard is initially tagged.

At each time , 25 lizards are captured, each lizard's zone is recorded, and they are released. The recorded 1, 2, or 3 corresponds to an actual zone, while 4 represents a missing value that could mean that the lizard was not captured or that it is dead.

 In[1]:= Xobs = TemporalData[Automatic, {CompressedData[" 1:eJyVVMFhw0AIM0JL9NkZsklHyALd/1dJ3OXVxDbJOXccEBDC38/fnyeO4/jS emh1dzWhp0QHklWQRg/UEp27bORrwvoGW2rdsS20NaNxnKLVGHUiwJeIMtdn AiDmCWBfnjrZzHmfB39J3zHePiyoRFz3AI1JAIrrgPLRxQjDqLkVnU0FOEHa CuKzcTVQDte7O/dKCbTTNUwgH1en3iQ26dwSdAiT0JFK9nSN5tDaxsbWw6mh mYvE8MhhTEQpe5g0XEzCiS2sWJeROOnBv7Iy43Ww0/OUmwr8NRQ6SpsilbM/ q6gF0bTBpdtHhxSKXjMZ2BSk89uDEDDJzcw5V45JYQHGgOZl8zLS3mWEncTy hqd86DB/Pm8IBmOuycxboT0QHTPs5i4GKRKG7mO8dxgC7FKceWj9mly3Efe6 A5OGvDJaW/4AyHsRTg== "], {{0, 50, 1}}, 25, {"Discrete", 25}, { "Discrete", 1}, 1, {ValueDimensions -> 1, MetaInformation -> {}}}, False, 10.];

Estimate a 4-state, 4-emission hidden Markov process from the data.

 In[2]:= Xeproc = EstimatedProcess[obs, HiddenMarkovProcess[4, 4]]
 Out[2]=

Find the most likely movement pattern for the first lizard.

 In[3]:= XFindHiddenMarkovStates[obs["Values"], eproc]
 Out[3]=

In the preceding sequence the state 1, death, is an absorbing state.

 In[4]:= Xdmp = DiscreteMarkovProcess[Chop[eproc]]; MarkovProcessProperties[dmp, "AbsorbingClasses"]
 Out[4]=

The mean time to death.

 In[5]:= XMean[FirstPassageTimeDistribution[dmp, 1]]
 Out[5]=

## Mathematica + Mathematica Online

Questions? Comments? Contact a Wolfram expert »