hmm.discnp (version 3.0-9)

cnvrtRho: Convert Rho between forms.

Description

Converts a matrix specification of the emission probabilities (in which the probabilities are simply the entries of the matrix) to a data frame specification (in which the probabilities are a logistic-style function of the parameters) or vice versa.

Usage

cnvrtRho(Rho)

Value

A data frame if the argument Rho is a matrix, or a matrix if the argument Rho is a data frame.

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.

Author

Rolf Turner r.turner@auckland.ac.nz

Details

The data frame specification of Rho allows for predictor variables x. If Rho is of the data frame form, and is designed to allow for predictor variables, then it will have more than three columns and cannot be converted to the matrix form. In such cases cnvrtRho will throw an error.

See Also

hmm()

Examples

Run this code
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