emMHMMR {samurais} | R Documentation |
emMHMMR implemens the EM (Baum-Welch) algorithm to fit a MHMMR model.
Description
emMHMMR implements the maximum-likelihood parameter estimation of the MHMMR model by the Expectation-Maximization (EM) algorithm, known as Baum-Welch algorithm in the context of HMMs.
Usage
emMHMMR(X, Y, K, p = 3, variance_type = c("heteroskedastic",
"homoskedastic"), n_tries = 1, max_iter = 1500, threshold = 1e-06,
verbose = FALSE)
Arguments
X |
Numeric vector of length m representing the covariates/inputs
|
Y |
Matrix of size |
K |
The number of regimes (MHMMR components). |
p |
Optional. The order of the polynomial regression. By default, |
variance_type |
Optional character indicating if the model is "homoskedastic" or "heteroskedastic". By default the model is "heteroskedastic". |
n_tries |
Optional. Number of runs of the EM algorithm. The solution providing the highest log-likelihood will be returned. If |
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. |
Details
emMHMMR function implements the EM algorithm. This function starts
with an initialization of the parameters done by the method initParam
of
the class ParamMHMMR, then it alternates between the E-Step
(method of the class StatMHMMR) and the M-Step (method of the
class ParamMHMMR) until convergence (until the relative
variation of log-likelihood between two steps of the EM algorithm is less
than the threshold
parameter).
Value
EM returns an object of class ModelMHMMR.
See Also
ModelMHMMR, ParamMHMMR, StatMHMMR
Examples
data(multivtoydataset)
mhmmr <- emMHMMR(multivtoydataset$x, multivtoydataset[,c("y1", "y2", "y3")],
K = 5, p = 1, verbose = TRUE)
mhmmr$summary()
mhmmr$plot()