R: Transform Transition or Rate Matrices to Vector

Transform-Parameters {HiddenMarkov} | R Documentation

## Transform Transition or Rate Matrices to Vector

### Description

These functions transform m*m transition probability matrices or Q matrices to a vector of length m(m-1), and back. See Details.

### Usage

    Pi2vector(Pi)
    vector2Pi(p)

    Q2vector(Q)
    vector2Q(p)

### Arguments

`Pi` | an m by m transition probability matrix.
`Q` | an m by m rate matrix.
`p` | a vector of length m(m-1).

### Details

The function `Pi2vector` maps the m by m transition probability matrix of a discrete time HMM to a vector of length m(m-1), and `vector2Pi` has the reverse effect. They use a logit like transformation so that the parameter space is on the whole real line thus avoiding hard boundaries which cause problems for many optimisation procedures (see `neglogLik`).

Similarly, the function `Q2vector` maps the m by m rate matrix Q of an MMPP process to a vector of length m(m-1), and `vector2Q` has the reverse effect. They use a log transformation so that the parameter space is on the whole real line thus avoiding hard boundaries which cause problems for many optimisation procedures (see `neglogLik`).

### Value

The functions `Pi2vector` and `Q2vector` return a vector of length m(m-1), the function `vector2Pi` returns an m by m transition probability matrix, and `vector2Q` returns an m*m rate matrix Q.

### See Also

`neglogLik`

### Examples

    Pi <- matrix(c(0.8, 0.1, 0.1,
                   0.1, 0.6, 0.3,
                   0.2, 0.3, 0.5),
                 byrow=TRUE, nrow=3)

    print(vector2Pi(Pi2vector(Pi)))

    #------------------------------------------------

    Q <- matrix(c(-8,  5,  3,
                   1, -4,  3,
                   2,  5, -7),
                byrow=TRUE, nrow=3)

    print(vector2Q(Q2vector(Q)))

[Package HiddenMarkov version 1.8-8 Index]