hhsmmfit function

hhsmm model fit

hhsmm model fit

Fits a hidden hybrid Markov-semi-Markov model to a data of class "hhsmmdata" and using an initial model created by hhsmmspec or initialize_model

hhsmmfit( x, model, mstep = NULL, ..., M = NA, par = list(maxit = 100, lock.transition = FALSE, lock.d = FALSE, lock.init = FALSE, graphical = FALSE, verbose = TRUE) )

Arguments

  • x: a data of class "hhsmmdata", which can also contain missing values (NA or NaN)

  • model: an initial model created by hhsmm.spec or initialize_model

  • mstep: the M step function for the EM algorithm, which also can be given in the model

  • ...: additional parameters for the dens.emission and mstep functions

  • M: the maximum duration in each state

  • par: additional list of control parameters of the hhsmmfit function including the following items:

    • maxit the maximum number of iterations for the EM algorithm
    • lock.transition logical. if TRUE the transition matrix will not be updated through the EM algorithm
    • lock.d logical. if TRUE the sojourn probability matrix d will not be updated through the EM algorithm
    • lock.init logical. if TRUE the initial probability vector will not be updated through the EM algorithm
    • graphical logical. if TRUE a plot of the sojourn probabilities will be plotted through the EM algorithm
    • verbose logical. if TRUE the outputs will be printed

Returns

a list of class "hhsmm" containing the following items:

  • loglike the log-likelihood of the fitted model
  • AIC the Akaike information criterion of the fitted model
  • BIC the Bayesian information criterion of the fitted model
  • model the fitted model
  • estep_variables the E step (forward-backward) probabilities of the final iteration of the EM algorithm
  • M the maximum duration in each state
  • J the number of states
  • NN the vector of sequence lengths
  • f the emission probability density function
  • mstep the M step function of the EM algorithm
  • yhat the estimated sequence of states

Examples

J <- 3 initial <- c(1, 0, 0) semi <- c(FALSE, TRUE, FALSE) P <- matrix(c(0.8, 0.1, 0.1, 0.5, 0, 0.5, 0.1, 0.2, 0.7), nrow = J, byrow = TRUE) par <- list(mu = list(list(7, 8), list(10, 9, 11), list(12, 14)), sigma = list(list(3.8, 4.9), list(4.3, 4.2, 5.4), list(4.5, 6.1)), mix.p = list(c(0.3, 0.7), c(0.2, 0.3, 0.5), c(0.5, 0.5))) sojourn <- list(shape = c(0, 3, 0), scale = c(0, 10, 0), type = "gamma") model <- hhsmmspec(init = initial, transition = P, parms.emis = par, dens.emis = dmixmvnorm, sojourn = sojourn, semi = semi) train <- simulate(model, nsim = c(10, 8, 8, 18), seed = 1234, remission = rmixmvnorm) clus = initial_cluster(train, nstate = 3, nmix = c(2 ,2, 2),ltr = FALSE, final.absorb = FALSE, verbose = TRUE) initmodel1 = initialize_model(clus = clus, sojourn = "gamma", M = max(train$N), semi = semi) fit1 = hhsmmfit(x = train, model = initmodel1, M = max(train$N))

References

Guedon, Y. (2005). Hidden hybrid Markov/semi-Markov chains. Computational statistics and Data analysis, 49(3), 663-688.

OConnell, J., & Hojsgaard, S. (2011). Hidden semi Markov models for multiple observation sequences: The mhsmm package for R. Journal of Statistical Software, 39(4), 1-22.

Author(s)

Morteza Amini, morteza.amini@ut.ac.ir , Afarin Bayat, aftbayat@gmail.com

  • Maintainer: Morteza Amini
  • License: GPL-3
  • Last published: 2024-09-04

Useful links