The value of stateProbs() and getTrProbs() functions can't match with each other? #183
-
Hi Brett, fitHaggis <- fitHMM(data = processedHaggis, nbStates = 2,
dist = list(step = "gamma", angle = "vm"),
Par0 = list(step = stepPar0, angle = anglePar0),
formula = ~ slope + I(slope^2),
estAngleMean = list(angle = TRUE)) Based on the code provided in "Guide to using momentuHMM.pdf - 2.2 HMM specification and fitting," I obtained the fitted model > sp <- stateProbs(fitHaggis)
> trProbs <- getTrProbs(fitHaggis)
> sp[1:5,]
state 1 state 2
[1,] 7.191524e-01 2.808476e-01
[2,] 2.174842e-06 9.999978e-01
[3,] 1.141769e-01 8.858231e-01
[4,] 8.933096e-01 1.066904e-01
[5,] 1.000000e+00 4.473818e-08
> trProbs[,,1:5]
, , 1
state 1 state 2
state 1 0.76818444 0.2318156
state 2 0.05158681 0.9484132
, , 2
state 1 state 2
state 1 0.61340077 0.3865992
state 2 0.03605583 0.9639442
, , 3
state 1 state 2
state 1 0.60749200 0.3925080
state 2 0.03961385 0.9603862
, , 4
state 1 state 2
state 1 0.7311696 0.2688304
state 2 0.1072474 0.8927526
, , 5
state 1 state 2
state 1 0.8384870 0.1615130
state 2 0.2341643 0.7658357
> sp[1,] %*% trProbs[,,1]
state 1 state 2
[1,] 0.5669297 0.4330703
> sp[1,] %*% trProbs[,,2]
state 1 state 2
[1,] 0.4512548 0.5487452 What confuses me is that If you know the reason for this, could you please enlighten me? Thank you very much! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
The same issue arises where |
Beta Was this translation helpful? Give feedback.
-
If I replace m <- example$m
sp <- stateProbs(m)
trProbs <- getTrProbs(m)
sp[1:5,]
trProbs[,,1:5]
sp[1,] %*% trProbs[,,1]
sp[1,] %*% trProbs[,,2] |
Beta Was this translation helpful? Give feedback.
-
Unless I'm missing something, the simple answer is that they shouldn't be equal. You should be able to verify this by examining the definitions/derivations of the state probabilities (i.e. "local" decoding based on the forward-backward algorithm) and the state transition probabilities in Zucchini et al. 2016 (or see this tutorial for abbreviated versions). |
Beta Was this translation helpful? Give feedback.
Unless I'm missing something, the simple answer is that they shouldn't be equal. You should be able to verify this by examining the definitions/derivations of the state probabilities (i.e. "local" decoding based on the forward-backward algorithm) and the state transition probabilities in Zucchini et al. 2016 (or see this tutorial for abbreviated versions).