Stata .ado to interlace rows into columns or columns into rows in matrices.
This program re-arranges columns and rows in a matrix in such a way that either:
- Rows are interlaced into colums: Formerly stacked cells appear beside each other.
- Columns are interlaced into rows: Cells formerly beside each other appear stacked.
The interlacing is done for a specified panel width/height and thus repeated for the number of panels in the matrix. You can specify the number of rows/columns to be interlaced. This is useful, for example, to re-arrange statistics.
Consider the following 6x2 matrix A
Model 1 | Model 2 | |
---|---|---|
b | 0.111 | 0.444 |
se | 0.011 | 0.044 |
b | 0.222 | 0.555 |
se | 0.022 | 0.055 |
b | 0.333 | 0.666 |
se | 0.033 | 0.066 |
You want to interlace the standard errors from rows into columns, so that they are printed in the column right of the beta values instead of being printed in the row below.
Using the command...
matil A, d(r2c) sp(1)
...would produce the desired result stored under A_matil (3x4)
Model 1 | Model 2 | |||
---|---|---|---|---|
b | se | b | se | |
Panel1 | 0.111 | 0.011 | 0.444 | 0.044 |
Panel2 | 0.222 | 0.022 | 0.555 | 0.055 |
Panel3 | 0.333 | 0.033 | 0.666 | 0.066 |
Please note that the 'Model' labels are for illustrative purposes only and do not appear as labels in the matrix. The 'Panel' labels, however, are added automatically.
net install matil, from("https://raw.githubusercontent.com/maximilian-sprengholz/matil/master/pkg/")
Please use the help-file installed with the package for details on syntax and options as well as further examples.
Maximilian Sprengholz
Humboldt-Universität zu Berlin
maximilian.sprengholz@hu-berlin.de