AIC.hmm: Evaulating Hidden Markov Models

Description Usage Arguments Details Functions Examples

View source: R/misc_methods.R

Description

Functions for evaluating model fitness of a hidden Markov model using AIC, BIC and log-likelihood.

Usage

1
2
3
4
5
6
7
8
## S3 method for class 'hmm'
AIC(object, ..., k = 2)

## S3 method for class 'hmm'
BIC(object, ...)

## S3 method for class 'hmm'
logLik(object, ...)

Arguments

object

Object of class hmm.

...

Optinally more fitted model objects.

k

numeric, the penalty per parameter to be used; the default k = 2 is the classical AIC

Details

The log-likelihood is calculated using a combination of the forward algorithm for finding the (regular) likelihood and the log-sum-exp-trick to properly convert this to a log-likelihood in order to avoid underflow. The AIC and BIC are calculated as usual, where the number of parameters is (m^2-1) + k where m is the number of states and k is the number of parameters in the emission distributions. This is because we estimate m*(m-1) probabilities in the transition matrix and m-1 probabilities in the initial distribution vector, i.e. (m+1)(m-1) = m^2-1 in all. All of this, however, is done during the creation of the hmm instance, so this function simply returns the values stored in the object.

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Continuation of Earthquake example


# Fitted model
AIC(hmm.EQ)
BIC(hmm.EQ)
logLik(hmm.EQ)

# Starting parameters
AIC(hmm.EQ_no_opt)
BIC(hmm.EQ_no_opt)
logLik(hmm.EQ_no_opt)

AdvancedR-2021/hmm documentation built on Dec. 17, 2021, 7:41 a.m.