Learn R Programming

ino (version 1.0.2)

f_ll_hmm: Log-likelihood function of a Gaussian-hidden Markov model

Description

Log-likelihood function of a Gaussian-hidden Markov model

Usage

f_ll_hmm(theta, data, N, neg = FALSE)

Value

A numeric, the log-likelihood value at theta given data.

Arguments

theta

A numeric vector of model parameters.

  • The first N*(N-1) elements are the logarithms of the non-diagonal elements of the transition probability matrix.

  • The next N elements are the mean values of the state-dependent normal distributions.

  • The last N elements are the logarithms of the standard deviations of the state-dependent normal distributions.

data

A numeric vector, the time series data.

N

An integer, the number of states.

neg

Set to TRUE to return the negative log-likelihood value.

References

https://en.wikipedia.org/wiki/Hidden_Markov_model

Examples

Run this code
theta <- c(-1, -1, -2, 2, 0.5, 0.5)
data <- sim_hmm(Tp = 1000, N = 2, theta = theta)
f_ll_hmm(theta = theta, data = data, N = 2)
# \donttest{
nlm(f_ll_hmm, p = theta, data = data, N = 2, neg = TRUE)$estimate
# }

Run the code above in your browser using DataLab