Learn R Programming

RcppHMM (version 1.0.1)

evaluation: Observed sequence evaluation given a model

Description

This function computes the log-likelihood of an observed sequence being generated by a hidden Markov model with fixed parameters.

Usage

evaluation(hmm , sequence , method = "f" )

Arguments

hmm

a list that contains all the necesary variables to define a hidden Markov model.

sequence

a vector that contains a sequence of observations to be evaluated.

method

method especified to do the evaluation

Value

A value that represents the log likelihood of the sequence given the hiddden Markov model.

Details

The methods to be selected can be "f" for the forward algorithm and "b" for the backward algorithm.

References

Cited references are listed on the RcppHMM manual page.

See Also

generateObservations , verifyModel , loglikelihood

Examples

Run this code
# NOT RUN {
# Set the model parameters
n <- c("First","Second")
m <- c("A","T","C","G")
A <- matrix(c(0.8,0.2,
              0.1,0.9),
            nrow = 2,
            byrow = TRUE)

B <- matrix(c(0.2, 0.2, 0.3, 0.3,
              0.4, 0.4, 0.1, 0.1),
            nrow = 2,
            byrow = TRUE)

Pi <- c(0.5, 0.5)

params <- list( "Model" = "HMM",
                "StateNames" = n,
                "ObservationNames" = m,
                "A" = A,
                "B" = B,
                "Pi" = Pi)

HMM <- verifyModel(params)

# Data simulation
set.seed(100)
length <- 100
observationSequence <- generateObservations(HMM, length)

#Sequence evaluation
evaluation(HMM, observationSequence$Y)
evaluation(HMM, observationSequence$Y, "b")
# }

Run the code above in your browser using DataLab