TOOLS > MATRIX ALGEBRA
PURPOSE Command-driven matrix algebra package.
DESCRIPTION Input and output are UCINET datasets. Capabilities are divided into functions and procedures, which have different syntax. Further, within functions we can distinguish three basic types:
Unary Operations. Those that operate on a single dataset and take no arguments (e.g. ABS, which takes the absolute value of every cell in the matrix);
Binary Operations. Those that perform algebraic and arithmetic operations require two or more datasets (e.g. ADD, which adds corresponding cells of two or more matrices);
Inner Products. Those that perform arithmetic operations on various dimensions (i.e. rows, columns, matrices) of a single dataset (e.g. TOTAL, which sums values of a matrix broken out by row, column, level or combinations of these).
When you choose Algebra from the menu, then a command window will open up. You can close the window by clicking on the close button. Commands are typed in the command window you can scroll back to previous commands by using the up and down arrows.
The difference in the two kinds of commands is reflected in their syntax.
Functions have this basic syntax:
<output matrix> = <function>(<arguments>)
In the documentation to follow, an item enclosed in angle brackets denotes a name or other input to be provided by the user. Hence, <output matrix> refers to the name of a dataset to be supplied by the user. Items enclosed in square brackets will denote optional arguments. Anything else, such as an equal sign or parenthesis, is something to be typed verbatim.
An example of valid syntax for a function is this:
y = inverse(x)
In the example, x is a pre-existing dataset in the current folder, inverse is the name of a function, and y is the name of a yet-to-be-created dataset to contain the inverse of the matrix in x. Datasets may be named using their full pathnames, as in:
a:tdavis = transpose(c:\ucinet\data\davis)
Most functions will have a single argument consisting of the name of an input matrix. Others will have two or more arguments, again consisting of the names of datasets. For instance, the syntax for the ADD command is as follows:
<matrix> = add(<matrix1>,<matrix2>,...)
An example would be:
mpx = add(business,marriage,friend)
A few functions take other kinds of arguments. For example, to generate an identity matrix with 5 rows and columns, you would type:
junk = identity(5)
The syntax for procedures differs from functions in that there is no output matrix:
An example is:
Another example is:
svd davis u d v
This requests a singular value decomposition of the matrix davis into three matrices (datasets) to be called u, d, and v.
One useful fact to remember is that whenever the syntax for a function or procedure calls for the name of a matrix, a function may be substituted instead. For example, the command
y = inverse(transpose(inf))
requests that the inverse of the transpose of a matrix inf be calculated and saved as dataset y. There is no limit to the amount of nesting. For example, the following command is perfectly valid, though neither efficient nor very readable:
b = prod(inv(prod(transp(x),x)),prod(transp(x),y))
A less error-prone alternative would be the following series:
xt = transp(x)
xtx = prod(xt,x)
xty = prod(xt,y)
b = prod(inv(xtx),xty)