hmm.discnp (version 2.1-5)

cnvrtRho: Convert Rho between forms.

Description

Converts the “old style” (matrix) specification of the emission probabilities to the “new style” (data frame) specification, or vice versa.

Usage

cnvrtRho(Rho)

Arguments

Rho

A specification of the emission probabilities of a discrete valued hidden Markov model. It may be either a matrix of these probabilities, in which case it is converted to a three column data frame, or it may be a three column data frame, in which case it is converted to a matrix of probabilities. See hmm() for more details about the structure of Rho, in either form.

Value

A data frame if the argument Rho is a matrix (“old style” specification), or a matrix if the argument Rho is a data frame (“new style” specification.

Details

The “new style” specification of Rho allows for predictor variables x. It Rho is of the “new style” and is designed to allow for predictor variables, then it will have more than three columns and cannot be converted to the “old style”. In such cases cnvrtRho will throw an error.

See Also

hmm()

Examples

Run this code
# NOT RUN {
Yval <- LETTERS[1:10]
Tpm  <- matrix(c(0.75,0.25,0.25,0.75),ncol=2,byrow=TRUE)
Rho  <- cbind(c(rep(1,5),rep(0,5)),c(rep(0,5),rep(1,5)))/5
rownames(Rho) <- Yval
newRho <- cnvrtRho(Rho)
oldRho <- cnvrtRho(newRho)
# }

Run the code above in your browser using DataLab