Learn R Programming

tileHMM (version 1.0-7)

contHMM-access: Accessing Objects of Class "contHMM"

Description

Access to model parameters and densities of emission distributions.

Usage

"["(x, i, j, transition = TRUE, log = FALSE, sum = TRUE, ...) "length"(x)

Arguments

x
Object of class contHMM
i
State for which parameter values should be retrieved. This can either a numeric value giving the state index or a character string with the state name.
j
Second index identifying parameter (see Details).
transition
Logical indicating whether transition probabilities or density values should be returned.
log
Logical indicating whether values should be log transformed before they are returned.
sum
Logical indicating whether densities of mixture components should be summed up. This is ignored if transition = TRUE.
...
Futher arguments to be passed to and from other methods.

Value

For ‘[’ either a subset of the transition probability matrix of x or the probability density of state i evaluated at point j (see Details). For ‘length’ the number of states in the model.

Details

The ‘[’ function allows access to the transition probability matrix of the model as well as the emission distributions. If transition = TRUE the transition probability matrix is accessed. In this case i and j identify rows and columns of the matrix respectively. Both can be given as either numeric index or name of the respective states. Either or both of i and j may be missing to indicate that an entire row or column should be selected. If transition = FALSE the emission distribution of state i is accessed instead. In this case the density function is evaluated at point j.

See Also

contHMM

Examples

Run this code
## create two state HMM with t distributions
state.names <- c("one","two")
transition <- c(0.1, 0.02)
location <- c(1, 2)
scale <- c(1, 1)
df <- c(4, 6)
hmm <- getHMM(list(a=transition, mu=location, sigma=scale, nu=df), 
    state.names)

## number of states in the model
length(hmm)

## transition probability from state 'one' to state 'two'
hmm["one", "two"]
## or equivalently
hmm[1, 2]

## get the transition probability matrix
hmm[ , ]

## evaluate emission distribution function of state 'one' at 0
hmm["one", 0, transition = FALSE]

## again, this time using log transformation
hmm["one", 0, transition = FALSE, log = TRUE]

Run the code above in your browser using DataLab