Hidden Markov Models for Life Sequences and Other Multivariate, Multichannel Categorical Time Series

Designed for fitting hidden (latent) Markov models and mixture hidden Markov models for social sequence data and other categorical time series. Also some more restricted versions of these type of models are available: Markov models, mixture Markov models, and latent class models. The package supports models for one or multiple subjects with one or multiple parallel sequences (channels). External covariates can be added to explain cluster membership in mixture models. The package provides functions for evaluating and comparing models, as well as functions for visualizing of multichannel sequence data and hidden Markov models. Models are estimated using maximum likelihood via the EM algorithm and/or direct numerical maximization with analytical gradients. All main algorithms are written in C++ with support for parallel computation. Documentation is available via several vignettes in this page, and the paper by Helske and Helske (2019, ).


News

seqHMM 1.1.0 (Release date: 2019-01-25)

  • Fixed iteration counter for EM algorithm, now maxeval=1 actually does one iteration and not two. Similarly fixed the the corresponding printing of intermediate results.
  • build_hmm and build_hmm now ignore n_states argument if any of the initial values are provided.
  • Updated some formulas in the algorithms vignette to correspond to current forward-backward variant.
  • Updated citation info due to the publication in JSS.

seqHMM 1.0.9 (Release date: 2018-11-06)

  • Fixed a bug in backward and posterior probabilities of multivariate models stemming from changes in version 1.0.7, causing the incorrect scaling factors. Note that issue was only in forward_backward and posterior_probs functions with log_scale = FALSE, internally the package still used correct implementations when calling fit_model. Thanks for Silvia Bacci for noticing the issue.
  • Fixed OpenMP flags in Makevars.

seqHMM 1.0.8-1 (Release date: 2018-05-03)

  • Fixed encoding issues in references.
  • Updated author affiliations.

seqHMM 1.0.8 (Release date: 2017-11-07)

  • Fixed a bug in forward_backward function, which did not provide correct scaling factors for last time point and thus the backward variables weren't scaled correctly.
  • Related to above bug, posterior_probs now provides proper probabilities between 0 and 1.
  • Fixed a bug in ssp; caused an error for sortv = "hidden.paths" when hidden paths were not provided even though x was an hmm object.
  • Changed argument withlegend to with.legend due to changes in the TraMineR package.
  • Related to the TraMineR update, fixed warnings given by ssp functions.
  • Fixing model plots after an update in the igraph package.

seqHMM 1.0.7 (Release date: 2017-04-04)

  • Added supplementary vignettes for visualization, estimation, and theoretical background.
  • Corrected a "feature" of the scaled forward-backward algorithm which caused potential numerical issues in backward probabilities. More specifically, previously the scaled backward variable at time t was scaled with the scaling factors c_[t+1] of the forward variable, instead of c_t. In typical applications this did not cause any problems, but some models which previously caused problems can work now without resorting to the log-space algorithm.
  • Scaling factors used in forward-backward algorithms are now stored as 1/c_t, where c_t are the scaling factors from older versions of seqHMM.
  • The build_mm function now automatically estimates model parameters from the observed initial state distribution and transition counts.
  • Added automatic starting values for build_hmm, build_mhmm, build_mmm, and build_lcm.

Bug fixes:

  • Fixed a bug from version 1.0.6 where the EM algorithm with restarts did not work as efficiently as intended due to changes in initializing emission matrices. More specifically, the previous version used Rcpp sugar which does not use deep copies in case of arma::cubes, which resulted the subsequent EM runs to depend on the first optimum (affecting especially the identification of non-zero emission probabilities).
  • Fixed a bug in the ssp function where tlim was taken account of after sorting sequences and computing hidden paths (now cases are chosen before other actions).

seqHMM 1.0.6 (Release date: 2016-08-01)

  • Argument diag_c in simulate_transition_probs is now used also in cases where left_right = FALSE.
  • Adjusted reltol and maxeval values for EM algorithm. Now reltol is 1e-10 (previously 1e-12), and the reltol and maxeval values for restarts are by default taken from the initial EM algorithm (previosly reltol was 1e-8 and maxeval = 100 for restarts).
  • Fixed hidden states labels for ssp functions (previously always used the default values).

Bug fixes:

  • The ssplot function assigned wrong colors for hidden states in cases where the state names were not alphabetically ordered. The performance of the function was also improved by removing extra calls to seqdef.
  • Changing the missing.color argument did not work in legends of ssp, ssplot, and mssplot.
  • The mssplot function now works with unique hidden state names (problem occured e.g. with latent class models).
  • The mssplot function with sortv = "mds.hidden" produced strange errors when plotting clusters with one hidden state. Now automatically uses "mds.obs" in such cases.

seqHMM 1.0.5 (Release date: 2016-02-24)

Bug fixes:

  • The mssplot function now uses hidden paths instead of posterior probabilities to determine the most probable cluster for each subject (previous solution caused errors when posterior probabilities suggested a different cluster than hidden paths).
  • In mssplot, removed a misplaced tlim which caused a warning when plotting state distributions of hidden paths.
  • The gridplot function now uses with.missing.legend also with combined legends.

seqHMM 1.0.4 (Release date: 2016-01-14)

  • Added examples for build_mmm.
  • Added more space for main titles in plot.mhmm.
  • Improved documentation.
  • Added tlim in ssp functions.

Bug Fixes:

  • Corrected mc_to_sc for single state models due to dimension dropping.
  • Corrected a bug in plot.hmm when layout = "vertical".
  • Fixed legend layout in plot.hmm.
  • Wrong nobs and df attributes in mc_to_sc.
  • Wrong number of sequences to ssp titles when tlim is used.
  • EM with HMM using log-space produced error due to missing element in output of EM.

seqHMM 1.0.3-1 (Release date: 2015-12-29)

As requested by CRAN, changed donttest example of interactive plotting to conditional block depending on whether session is interactive or not.

seqHMM 1.0.3 (Release date: 2015-12-23)

Corrected dependency on R 3.2.0 due to lengths function.

Bug Fixes:

  • Corrected a bug which caused fit_model to stop if restarted EM failed.
  • vcov.mhmm produced errors in valgrind, corrected issue by replacing Armadillo's inv_sympd function with inv.
  • Corrected a bug relating to colorpalette in mc_to_sc function.

Performance improvements:

  • Slight performance improvement in all functions by tweaking the usage of armadillo constructors.

seqHMM 1.0.2-1 (Release date: 2015-12-19)

First version on CRAN.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("seqHMM")

1.0.10 by Jouni Helske, 2 months ago


Report a bug at https://github.com/helske/seqHMM/issues


Browse source code at https://github.com/cran/seqHMM


Authors: Jouni Helske [aut, cre] , Satu Helske [aut]


Documentation:   PDF Manual  


GPL (>= 2) license


Imports gridBase, igraph, Matrix, nloptr, numDeriv, Rcpp, TraMineR, graphics, grDevices, grid, methods, stats, utils

Suggests MASS, nnet, knitr

Linking to Rcpp, RcppArmadillo

System requirements: C++11


Imported by DBHC.


See at CRAN