A useful transformation for Markov Chain using matrix operations.

154 Views Asked by At

I'm working with Markov chains in Python and I need to transform the transition matrix in order to facilitate some statistical estimation and I don't know what kind of matrix operations I could use.

In particular, I have a $J\times J$ transition matrix $P$ $$P=\begin{bmatrix}p_{11}&\dots&p_{1J}\\ p_{21}&\dots&p_{2J}\\ \vdots&\dots&\vdots\\ p_{J1}&\dots&p_{JJ}\end{bmatrix}$$

I need to apply the following transformation to $P$:

$$P^*= \begin{bmatrix}\mathbb{0}_{1xJ}&p_{2\bullet}&...&p_{J\bullet}\\ p_{1\bullet}&\mathbb{0}_{1xJ}&...&p_{J\bullet} \\ \vdots & \vdots & ...&\vdots\\ p_{1\bullet}&p_{2\bullet}&...&\mathbb{0}_{1xJ} \end{bmatrix}$$ where $p_{i\bullet}=\begin{bmatrix}p_{i1} & p_{i2}&...&p_{iJ}\end{bmatrix}$ (i.e. the i-th row of $P$), $\mathbb{0}_{Jx1}$ is a zero vector of $J\times 1$ shape and $P^*$ is a $J\times JJ$ matrix.

I know this is different from using kronecker product with a ones-vector like this $$P \otimes\mathbb{1}_{[J\times 1]} \text{ or like } \mathbb{1}_{[J\times 1]}\otimes P $$ where $\mathbb{1}_{[J\times 1]}$ is a ones row vector.

I would greatly appreciate any idea about how to express this transformation using the usal matrix operations (e.g. Kronecker product, Hadamard product, or other else).

I'd very gratefull if someone can help me. Greetings!

1

There are 1 best solutions below

1
On BEST ANSWER

This was too big for a comment.

Since $J$ looks terrible as a subscript, let's use $n$ and $m=(n+1)$ instead.
Let's also use $e_k$ as the standard basis for ${\mathbb R}^{n}$, and $\varepsilon_k$ as the standard basis for ${\mathbb R}^{n^2}$ $$\eqalign{ P^* &= \Big(P\otimes{\large\tt1}_n-P\otimes I_n\Big)^T &\Big[&e_1\otimes e_1\quad&e_2\otimes e_2\quad &e_3\otimes e_3\quad&e_4\otimes e_4\quad&\ldots\quad&e_n\otimes e_n&\Big] \\ &=\Big(P\otimes{\large\tt1}_n-P\otimes I_n\Big)^T &\Big[&\varepsilon_1\quad&\varepsilon_{1+m}\quad&\varepsilon_{1+2m}\quad&\varepsilon_{1+3m}\;&\ldots\;&\varepsilon_{n^2}&\Big] \\ }$$ where $\{{\large\tt1}_n,\,I_n\}\,$ are the all-ones and identity matrices of order $n$.