Learn R Programming

HiddenMarkov (version 1.8-13)

logLik: Log Likelihood of Hidden Markov Model

Description

Provides methods for the generic function logLik.

Usage

# S3 method for dthmm
logLik(object, fortran=TRUE, ...)
# S3 method for mmglm0
logLik(object, fortran=TRUE, ...)
# S3 method for mmglm1
logLik(object, fortran=TRUE, ...)
# S3 method for mmglmlong1
logLik(object, fortran=TRUE, ...)
# S3 method for mmpp
logLik(object, fortran=TRUE, ...)

Arguments

object

an object with class "dthmm", "mmglm0", "mmglm1", "mmglmlong1" or "mmpp".

fortran

logical, if TRUE (default) use the Fortran code, else use the R code.

...

other arguments.

Value

Returns the value of the log-likelihood.

Details

The methods provided here will always recalculate the log-likelihood even if it is already contained within the object. This enables the user to change parameter or data values within the object and recalculate the log-likelihood for the revised configuration.

The code for the methods "dthmm", "mmglm0", "mmglm1","mmglmlong1" and "mmpp" can be viewed by appending logLik.dthmm, logLik.mmglm0, logLik.mmglm1, logLik.mmglmlong1 or logLik.mmpp, respectively, to HiddenMarkov:::, on the R command line; e.g. HiddenMarkov:::dthmm. The three colons are needed because these method functions are not in the exported NAMESPACE.

Examples

Run this code
# NOT RUN {
Pi <- matrix(c(1/2, 1/2,   0,
               1/3, 1/3, 1/3,
                 0, 1/2, 1/2),
             byrow=TRUE, nrow=3)

x <- dthmm(NULL, Pi, c(0,1,0), "norm",
           list(mean=c(1, 6, 3), sd=c(1, 0.5, 1)))

x <- simulate(x, nsim=100)

print(logLik(x))
# }

Run the code above in your browser using DataLab