Fitting a HMM with multiple known states and TPM constraints #190
-
Hi Brett, I hope you're doing well! However, I want to extend this model a little and add complexity. I would like to break the "rest" state down into "haulout" and at-sea rest ("surface") based on majority rule for time spent in haulout. So, effectively a 4 state model with two known states: haulout (state1) and surface (state2), as well as ARS (state3) and transit (state4). Of course I could just fit one known state and assign to at-sea or haulout post-hoc, but I am interested in the transition probabilities from the other states, and whether or not distinguishing between these two resting states may impact the inference of ARS and transit states. I'm having a little trouble parameterising beta0 to constrain the TPM and avoid switching into or out of either known state when they are not active (i.e. I don't want the model to assign state 1 when haulout == 0, and likewise it should not assign state 2 when surface == 0). Playing around with it, it seems beta0 expects a 3-row matrix, with the first row being (Intercept), the second being haulout1, and the third being surface1. I have been working on the assumption that (Intercept) is when neither known state is active, but I'm not sure this is correct. I am still getting instances where transitions into haulout or surface are happening from either ARS or transit when the known states are not active. I note that in your response to Will, you suggest setting workbounds as extra insurance... I have not found this to be necessary in my case to get the desired effect with one known state, however I thought it may help here. I tried to set this up but it seems the model wants a delta0 object of length 9, which confused me somewhat as I'm not sure what it's expecting; 9 would imply a matrix of 3x3... so I'm not sure what the columns and rows should correspond to. Any advice greatly appreciated! Code below:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You're close, but the
|
Beta Was this translation helpful? Give feedback.
You're close, but the
-100
s should only be in the first row forbeta0
. Here's an extension of the #68 example with two known states, I think it will do what you want but please be sure to play around with it and verify: