Title

matrow -- Matrix operations on rows made simple | 2014-10-24

meanabs 2014-10-24
keep(numlist) 2014-10-24 keep these columns

General syntax

Rows are rows in the input matrix. The rowtochange can be a new row.

Binary operations on two rows

matrow inputmatrix rowtochange = leftrow operator rightrow
[, name(new-row-name)]

Unary operations on rows

matrow inputmatrix rowtochange = operator(row)
[, name(new-row-name)]

Statistics summarizing rows in matrix

matrow inputmatrix rowtochange = operator
[, rows(rows-to-analyze)
name(new-row-name)]

Add row containing row numbers

matrow inputmatrix rowtochange = name [, rows(numlist)]

Rename existing row

matrow inputmatrix, rows(numlist)]

Matrix

inputmatrix is the matrix to be modified. The original
is overwritten if rowtochange is an existing row.

Specifying rows

The rows that is changed and the rows used to create the new row are specified as follows:

# Row index; if # exceeds dimension of matrix, extra rows with missing values are added.

n Add one row to bottom of matrix.

l Last row in matrix (lower case L).

p Prior row created by adding row at top of matrix.

rowtochange the row to be changed in inputmatrix. If the row does not exist (e.g., row 5 in a 3x3 matrix) additional rows filled with missing values .z are added.

leftrow in binary operations, this is the row to the left of the operator.

rightrow in binary operations, this is the row to the right of the operator.

row in unary operations, this row is modified to create the rowtochange.

Options for all types of operations

list
List matrix after changes.

format(fmt)
Use fmt to format listing; default is %9.3f.

width(integer)
Width used in format; default is 9.

decimals(integer)
Decimals used in format; default is 3.

name(label)
the changed row is given this row name in the matrix.

Overview

matrow makes changes to the matrix based on row operations
such as adding two rows, summing over rows, taking the square root of a row.

Expanded syntax

Binary operations

matrow inputmatrix rowtochange = leftrow operator rightrow

Operator What it does

+ Addition of left and right

- Subtraction left from right

* Multiplication left times right

/ Division left by right

^ Exponentiation of left to right power

%of Left as percent of right

%dif Change from left to right as percent of left

Unary operations

matrow inputmatrix rowtochange = operator(row)

Operator What it does

abs Absolute value

exp Exponential

inv Inverse

log10 Log base 10

log10 Logit = log[ x/(1-x) ]

log Natural log

log Odds = x/(1-x)

sq Square

sqrt Square root

Statistics

matrow inputmatrix rowtochange = operator [, rows(numlist)]

For each column, statistics are computed based on information in the rows. The rows(numlist) option lets you select which rows to use in computing statistics.

Operator What it does

max Maximum of selected rows

mean Mean of selected rows.

min Minimum of selected rows

range Range of selected rows.

sd Standard deviation of selected rows.

var Variance of selected rows.

rows(numlist)
Select rows from inputmatrix that are used when computing statistics.

Utility

matrow inputmatrix rowtochange = operator

Operator What it does

number Create a row indicting the column number.

Author

Scott Long
Home
SPost
Workflow