Title

_rm_matrix_select --
Select rows or columns from a matrix using a selection vector and the
mata select() function.

Syntax

_rm_matrix_select
input-matrix
select-vector
(row | col)
[ name-string ]

inpuat-matrix Name of matrix that is to be revised.

select-vector Name of row vector where each element
corresponds to a column or row in the input-matrix.
If an elment is 1, that row or column will be selected.

row | col Select based on rows or columns.

name-string Names for each row/column of the input
matrix that will be assigned to the revised matrix. This allows you to
change row/column names.

Description

_rm_matrix_select is a programmer's tool that
makes selections using a selection vector that is passed to
mata's select() comand. The revised matrix keeps the rows and
columns in the same order as before selection. To change the order,
see _rm_matrix_index which allows a reordering of rows
or columns.
If you want to
select both rows and columns, run the command twice, once with the row option,
then with the col option.

Saved results

The changed matrix is returned to with the same name. If you want the
to preserve the matrix before the selection, you must save another copy
of the matrix before running this command.

Also see

_rm for other _rm programming commands.