Data

Position of the animal collected every 8 minutes from July the 23rd (06:28) to July the 24th 2015 (06:36). The speed (km/h) and spatial angle between two successive moves have been computed.

Response variable (\(t = 1 \dots n = 179\)): \[ Y_t = (\text{speed at time $t$}, \text{relative angle at time $t$}) \] (Source: Patin & al., Journal of Animal Ecology, 2019.)

Aim

Distinguishing between different types of behaviors

Hidden Markov model for the speed

Model

\(Y_t =\) speed at time \(t\): \[\begin{align*} Z = (Z_t) & \sim MC(\nu, \pi), \\ (Y_t) \text{ indep.} \mid Z: \qquad (Y_t \mid Z_t = k) & \sim \mathcal{N}(\mu_k, \sigma^2_k) \end{align*}\]

Parameter inference

library(depmixS4)
K <- 3
hmm1 <- depmix(speed ~ 1, data=move, nstates=K, family=gaussian(), ntimes=n, 
               emcontrol=em.control(random.start = FALSE))
fit1 <- fit(hmm1)
## converged at iteration 51 with logLik: -853.3333
summary(fit1)
## Initial state probabilities model 
## pr1 pr2 pr3 
##   1   0   0 
## 
## Transition matrix 
##         toS1  toS2  toS3
## fromS1 0.847 0.054 0.100
## fromS2 0.025 0.869 0.106
## fromS3 0.174 0.074 0.751
## 
## Response parameters 
## Resp 1 : gaussian 
##     Re1.(Intercept) Re1.sd
## St1           5.099  4.173
## St2         255.085 92.502
## St3          36.913 20.769

Hidden path

Comparison between ‘maximum a posteriori’ and most probable path: \[ MAP_t = \arg\max_k \tau_{tk}, \qquad \widehat{Z} = \arg\max_z \Pr\{Z = z \mid Y\}. \]

##             S1           S2           S3 vit1 map1
## 1 1.000000e+00 0.0000000000 0.000000e+00    1    1
## 2 9.789449e-01 0.0001746294 2.088047e-02    1    1
## 3 8.073945e-01 0.0013925583 1.912129e-01    3    1
## 4 3.130094e-23 0.0066521205 9.933479e-01    3    3
## 5 0.000000e+00 1.0000000000 4.892985e-34    2    2
## 6 0.000000e+00 1.0000000000 6.890507e-23    2    2
##     vit1
## map1  1  2  3
##    1 69  0  4
##    2  0 56  0
##    3  0  2 48

Model selection

## converged at iteration 1 with logLik: -1115.984 
## converged at iteration 14 with logLik: -927.8952 
## converged at iteration 49 with logLik: -853.3333 
## converged at iteration 56 with logLik: -845.3459 
## converged at iteration 89 with logLik: -836.6141
##              1         2         3         4         5
## df       2.000    7.0000   14.0000   23.0000   34.0000
## logL -1115.984 -927.8952 -853.3333 -845.3459 -836.6141
## BIC  -1121.172 -946.0511 -889.6450 -905.0008 -924.7996

Hidden Markov model for the speed and angle

Model

\(Y_t = (Y_{1t}, Y_{2t})\): \(Y_{1t} =\) speed at time \(t\), \(Y_{2t} =\) (relative) angle at time \(t\), : \[\begin{align*} Z = (Z_t) & \sim MC(\nu, \pi), \\ (Y_t) \text{ indep.} \mid Z: \qquad \left(\left[\begin{array}{c} Y_{1t} \\ Y_{2t} \end{array} \right] \mid Z_t = k \right) & \sim \mathcal{N}\left( \left[\begin{array}{c} \mu_{1k} \\ \mu_{2k} \end{array} \right], \left[\begin{array}{cc} \sigma^2_{1k} & 0 \\ 0 & \sigma^2_{2k} \end{array} \right] \right) \end{align*}\]

## converged at iteration 59 with logLik: -921.646
## Initial state probabilities model 
## pr1 pr2 pr3 
##   1   0   0 
## 
## Transition matrix 
##         toS1  toS2  toS3
## fromS1 0.847 0.100 0.053
## fromS2 0.144 0.778 0.078
## fromS3 0.042 0.079 0.878
## 
## Response parameters 
## Resp 1 : gaussian 
## Resp 2 : gaussian 
##     Re1.(Intercept)  Re1.sd Re2.(Intercept) Re2.sd
## St1           4.771   3.843           0.696  0.353
## St2          33.138  19.447           0.712  0.674
## St3         243.257 100.760           0.241  0.189
##     vit2
## vit1  1  2  3
##    1 68  1  0
##    2  0  1 57
##    3  0 48  4

Hidden path

The \(K = 3\) states can be interpreted as ‘standing’, ‘feeding’, ‘transiting’.