Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hidden_paths does not respect sequence length #58

Closed
tbeason opened this issue Mar 30, 2022 · 4 comments
Closed

hidden_paths does not respect sequence length #58

tbeason opened this issue Mar 30, 2022 · 4 comments

Comments

@tbeason
Copy link

tbeason commented Mar 30, 2022

Perhaps I am missing something, but if I input sequence data where each sequence is a different length and estimate an HMM, running mpp <- hidden_paths(hmm$model) results in a "dense" matrix (all observations are assigned a state and no voids appear). Are there options to have it respect the void elements? Should I just set those to void ex post?

This is particularly problematic for me because I am then calling things like dur_output <- seqistatd(mpp) which of course gives nonsense results because the mpp sequences have these psuedo elements added relative to the original input data.

@helske
Copy link
Owner

helske commented Mar 31, 2022

The hidden_paths function computes the most probable states also for the missing values, which is how unequal sequence lengths are handled internally. But indeed, it makes often sense to set the tails to voids for visualization etc. I'll add an an option for this.

@tbeason
Copy link
Author

tbeason commented Mar 31, 2022

In my case, and I suspect in many cases, they are not true "missing" observations. The sequences simply have different length. I will add a check in my code to reset these positions to void until you are able to add this option.

helske added a commit that referenced this issue Apr 1, 2022
@helske
Copy link
Owner

helske commented Apr 1, 2022

Yes this makes sense. I just pushed an update, the hidden_paths function now has an argument respect_void (default is TRUE) which replaces the hidden states with voids according to the observed sequences. Let me know if you encounter problems, I didn't fully test this yet.

@tbeason
Copy link
Author

tbeason commented Apr 26, 2022

Seems to be working fine. Thanks for the quick fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants