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) )
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 algorithmlock.transition
logical. if TRUE the transition matrix will not be updated through the EM algorithmlock.d
logical. if TRUE the sojourn probability matrix d will not be updated through the EM algorithmlock.init
logical. if TRUE the initial probability vector will not be updated through the EM algorithmgraphical
logical. if TRUE a plot of the sojourn probabilities will be plotted through the EM algorithmverbose
logical. if TRUE the outputs will be printeda list of class "hhsmm"
containing the following items:
loglike
the log-likelihood of the fitted modelAIC
the Akaike information criterion of the fitted modelBIC
the Bayesian information criterion of the fitted modelmodel
the fitted modelestep_variables
the E step (forward-backward) probabilities of the final iteration of the EM algorithmM
the maximum duration in each stateJ
the number of statesNN
the vector of sequence lengthsf
the emission probability density functionmstep
the M step function of the EM algorithmyhat
the estimated sequence of statesJ <- 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))
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.
Morteza Amini, morteza.amini@ut.ac.ir , Afarin Bayat, aftbayat@gmail.com
Useful links