ll_hmm {fHMM} | R Documentation |
Log-likelihood function of an (H)HMM
Description
This function computes the log-likelihood value of a (hierarchical) hidden Markov model for given observations and parameter values.
Usage
ll_hmm(
parUncon,
observations,
controls = list(),
hierarchy = FALSE,
states = if (!hierarchy) 2 else c(2, 2),
sdds = if (!hierarchy) "normal" else c("normal", "normal"),
negative = FALSE,
check_controls = TRUE
)
Arguments
parUncon |
An object of class
|
observations |
A In the hierarchical case ( |
controls |
Either a The
Either none, all, or selected elements can be specified. Unspecified parameters are set to their default values. Important: Specifications in |
hierarchy |
A If By default, |
states |
An If By default, |
sdds |
A
The distribution parameters, i.e. the
can be fixed via, e.g., If By default, |
negative |
Either |
check_controls |
Either |
Value
The (negative) log-likelihood value.
Examples
### HMM log-likelihood
controls <- set_controls(states = 2, sdds = "normal")
parameters <- fHMM_parameters(controls)
parUncon <- par2parUncon(parameters, controls)
observations <- 1:10
ll_hmm(parUncon, observations, controls)
### HHMM log-likelihood
controls <- set_controls(
hierarchy = TRUE, states = c(2, 2), sdds = c("normal", "normal")
)
parameters <- fHMM_parameters(controls)
parUncon <- par2parUncon(parameters, controls)
observations <- matrix(dnorm(110), ncol = 11, nrow = 10)
ll_hmm(parUncon, observations, controls)