X: Numeric vector of length m representing the covariates/inputs x1,…,xm.
Y: Matrix of size (n,m) representing the observed responses/outputs. Y consists of n functions of X observed at points 1,…,m.
K: The number of clusters (Number of HMMR models).
R: The number of regimes (HMMR components) for each cluster.
p: Optional. The order of the polynomial regression. By default, p is set at 3.
variance_type: Optional. character indicating if the model is "homoskedastic" or "heteroskedastic". By default the model is "heteroskedastic".
order_constraint: Optional. A logical indicating whether or not a mask of order one should be applied to the transition matrix of the Markov chain to provide ordered states. For the purpose of segmentation, it must be set to TRUE (which is the default value).
init_kmeans: Optional. A logical indicating whether or not the curve partition should be initialized by the K-means algorithm. Otherwise the curve partition is initialized randomly.
n_tries: Optional. Number of runs of the EM algorithm. The solution providing the highest log-likelihood will be returned.
If n_tries > 1, then for the first run, parameters are initialized by uniformly segmenting the data into K segments, and for the next runs, parameters are initialized by randomly segmenting the data into K contiguous segments.
max_iter: Optional. The maximum number of iterations for the EM algorithm.
threshold: Optional. A numeric value specifying the threshold for the relative difference of log-likelihood between two steps of the EM as stopping criteria.
verbose: Optional. A logical value indicating whether or not values of the log-likelihood should be printed during EM iterations.
Returns
EM returns an object of class ModelMixHMMR .
Details
emMixHMMR function implements the EM algorithm. This function starts with an initialization of the parameters done by the method initParam of the class ParamMixHMMR , then it alternates between the E-Step (method of the class StatMixHMMR ) and the M-Step (method of the class ParamMixHMMR ) until convergence (until the relative variation of log-likelihood between two steps of the EM algorithm is less than the threshold parameter).
Examples
data(toydataset)x <- toydataset$x
Y <- t(toydataset[,2:ncol(toydataset)])mixhmmr <- emMixHMMR(X = x, Y = Y, K =3, R =3, p =1, verbose =TRUE)mixhmmr$summary()mixhmmr$plot()