Skip to content

Hidden state as lines in figure. #32

Closed Answered by TheoMichelot
MF214 asked this question in Q&A
Discussion options

You must be logged in to vote

Am I understanding correctly that the plot shows the state-dependent mean parameter as a red line? You could get the information required to produce this plot from a fitted HMM model. In particular, you could use $par() to get the estimated state-dependent mean parameters, and $viterbi() to get the most likely state sequence.

I'm including an example based on simulated data below. I fit a 2-state normal HMM to simulated data, and then get the estimated parameters and decoded states to create the graph. Here is the result.

library(hmmTMB)
set.seed(4634)

###################
## Simulate data ##
###################
n <- 500
tpm <- matrix(c(0.95, 0.01, 0.05, 0.99), 2, 2)
S <- rep(1, n)
for(i in

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MF214
Comment options

Answer selected by TheoMichelot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants