Everytime I fit my HMM, the obtained labels of states that I get are different. Sometimes State 1 is of negative mean and high std. deviation response parameters and sometimes State 2 is of negative mean and high std. deviation. I have tried setting seed set.seed(1) everytime I am fitting my model (multiple times in the same code block). Is there a way to set constraints in the fit function to always get label 1 as the label for the negative mean and high std. deviation state.

1 Answer 1

In depmixS4, you can set constraints on the parameters through the conrows, conrows.upper, and conrows.lower arguments in the fit function. Through these arguments, you force the mean in state 1 to be lower than the mean in state 2 by setting a constraint on the difference between these means, e.g.

$$\overline{Y}_1 - \overline{Y}_2 < 0$$

For more information, there is an example in the help file for the fit function. See

?depmixS4::fit

Another option would be to estimate the model as unconstrained, and then re-order the states afterwards. See https://stackoverflow.com/a/62533421/13797727