emHMMR implements the maximum-likelihood parameter estimation of the HMMR model by the Expectation-Maximization (EM) algorithm, known as Baum-Welch algorithm in the context of HMMs.
emHMMR(X, Y, K, p = 3, variance_type = c("heteroskedastic",
"homoskedastic"), n_tries = 1, max_iter = 1500, threshold = 1e-06,
verbose = FALSE)
Numeric vector of length m representing the covariates/inputs \(x_{1},\dots,x_{m}\).
Numeric vector of length m representing the observed response/output \(y_{1},\dots,y_{m}\).
The number of regimes/segments (HMMR components).
Optional. The order of the polynomial regression. By default, p
is
set at 3.
Optional character indicating if the model is "homoskedastic" or "heteroskedastic" (i.e same variance or different variances for each of the K regmies). By default the model is "heteroskedastic".
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.
Optional. The maximum number of iterations for the EM algorithm.
Optional. A numeric value specifying the threshold for the relative difference of log-likelihood between two steps of the EM as stopping criteria.
Optional. A logical value indicating whether or not values of the log-likelihood should be printed during EM iterations.
EM returns an object of class ModelHMMR.
emHMMR function implements the EM algorithm for the HMMR model. This
function starts with an initialization of the parameters done by the method
initParam
of the class ParamHMMR, then it alternates between
the E-Step (method of the class StatHMMR) and the M-Step
(method of the class ParamHMMR) until convergence (until the
relative variation of log-likelihood between two steps of the EM algorithm
is less than the threshold
parameter).
# NOT RUN {
data(univtoydataset)
hmmr <- emHMMR(univtoydataset$x, univtoydataset$y, K = 5, p = 1, verbose = TRUE)
hmmr$summary()
hmmr$plot()
# }
Run the code above in your browser using DataLab