| fit_model | R Documentation |
This function fits a hidden Markov model via numerical likelihood maximization.
fit_model(
data,
controls = data[["controls"]],
fit = list(),
runs = 10,
origin = FALSE,
accept = 1:3,
gradtol = 0.01,
iterlim = 100,
print.level = 0,
steptol = 0.01,
ncluster = 1,
seed = NULL,
verbose = TRUE,
initial_estimate = NULL
)
data |
[ |
controls |
[ The
Either none, all, or selected elements can be specified. Unspecified parameters are set to their default values. Important: Specifications in |
fit |
[ The
Either none, all, or selected elements can be specified. Unspecified parameters are set to their default values, see below. Specifications in |
runs |
[ By default, |
origin |
[ In this case, a By default, |
accept |
[ By default, |
gradtol |
[ By default, |
iterlim |
[ By default, |
print.level |
[ By default, |
steptol |
[ By default, |
ncluster |
[ |
seed |
[ |
verbose |
[ |
initial_estimate |
[
|
Multiple optimization runs starting from different initial values are
computed in parallel if ncluster > 1.
An object of class fHMM_model.
### 2-state HMM with normal distributions
# set specifications
controls <- set_controls(
states = 2, sdds = "normal", horizon = 100, runs = 10
)
# define parameters
parameters <- fHMM_parameters(controls, mu = c(-1, 1), seed = 1)
# sample data
data <- prepare_data(controls, true_parameter = parameters, seed = 1)
# fit model
model <- fit_model(data, seed = 1)
# inspect fit
summary(model)
plot(model, "sdds")
# decode states
model <- decode_states(model)
plot(model, "ts")
# predict
predict(model, ahead = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.