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

View source: R/functions.R

f_ll_hmmR Documentation

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)

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.

Value

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

References

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

Examples

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)

nlm(f_ll_hmm, p = theta, data = data, N = 2, neg = TRUE)$estimate



ino documentation built on Sept. 29, 2023, 5:09 p.m.