Matrix representation for panel data

65 Views Asked by At

Consider the following panel data matrix

individuals $n = 3$, time periods $t = 2$, and variables $p=2$. The design matrix
$\mathbf{X} = \big(\mathbf{x}_1 \,\, \mathbf{x}_2 \big) = \begin{pmatrix} 2&1\\-1&8 \\ 4&6\\3&-3 \\ 9&5\\11&7 \end{pmatrix}_{nt \times p}$

I want to diagonalize each column w.r.t. each individual and then put them next to each other as follows:

$\mathbf{Z} = \begin{pmatrix} 2&0&0&1&0&0\\-1&0&0&8&0&0 \\ 0&4&0&0&6&0\\0&3&0&0&-3&0 \\ 0&0&9&0&0&5\\0&0&11&0&0&7 \end{pmatrix}_{nt\times np} $

To represent this in matrix multiplication, I did the following

  • define a selection matrix $\mathbf{D}_{nt \times n} = \boldsymbol{I}_{n\times n} \otimes \mathbf{1}_{t\times 1}$
  • $\mathbf{Z} = \Big[\big(\mathbf{1}_{n\times 1}^{\tau} \otimes \mathbf{x}_1\big) \odot \mathbf{D}, \big(\mathbf{1}_{n\times 1}^{\tau} \otimes \mathbf{x}_2\big) \odot \mathbf{D} \Big]$ where $\otimes$ and $\odot$ are the kronecker and the element-wise products, respectively.

This absolutely does what I am looking for, yet I am looking forward to a much easier matrix representation.

1

There are 1 best solutions below

0
On BEST ANSWER

Extend your idea to its logical conclusion by defining the following zero-one matrices $$\eqalign{ \def\o{{\tt1}} \def\I{{I}} \def\LR#1{\left(#1\right)} \def\BR#1{\Big(#1\Big)} \def\R#1{\in{\mathbb R}^{#1}} P &= \I_p\otimes\o_n^T \\ S &= \o_p^T\otimes\I_n\otimes\o_t \\ }$$ Then you can convert the whole $X$ matrix in one step $$\eqalign{ Z &= \LR{XP}\odot S \\ }$$ To be clear, $\,\o_p\R{p}$ is a column vector of ones, and $I_n\R{n\times n}$ is the identity matrix.