Learn R Programming

HiddenMarkov (version 1.8-13)

Transform-Parameters: Transform Transition or Rate Matrices to Vector

Description

These functions transform \(m \times 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)\).

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 \times m\) rate matrix \(Q\).

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).

See Also

neglogLik

Examples

Run this code
# NOT RUN {
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)))
# }

Run the code above in your browser using DataLab