Statistica Visual Basic Matrix Language - Overview
Statistica Visual Basic includes an integrated, powerful Matrix language allowing you to develop your own Statistical and other computational programs by writing compact code referencing a comprehensive library of highly optimized matrix procedures. The supported Matrix Language operations include a complete matrix algebra language and a comprehensive selection of specialized procedures that are particularly useful in the development of custom Statistical applications:
· functions for computing the determinant, inverse, eigenvalues, eigenvectors, sweeping, GramSchmidt orthonormalization, Cholesky decomposition, singular values, singular value decomposition, matrix rank, solutions to linear equations, general pseudo-inverse;
· functions for computing correlations and covariances (with or without the intercept);
· functions for extracting specific columns, rows, submatrices, a diagonal, transposing, and combining matrices;
· addition, subtraction, multiplication, division by scalar (for each element of the matrix);
· addition, subtraction, multiplication of matrices;
· elementwise relational operators (<, <=, >, >=, =, not =);
· elementwise logical operators (not, and, or);
· tests for all elements 0, any element 0;
· options to read matrices from Statistica data files or ASCII text files, and save them as Statistica data files or ASCII text files.
The Matrix Language procedures of macro (SVB) programs make the programming of even sophisticated Statistical procedures quick, easy, and extremely efficient. For example, developing a customized multiple regression procedure takes just a few lines of code. Also, the output from your custom procedures can be easily handled in a most "professional" and efficient manner (see Output from Statistica Visual Basic), so that your custom procedures will look like "a part of Statistica."
Matrix Language procedures may be applied to the current data file to perform many common data management procedures (see Data Management Functions).
- Matrices and Vectors
- Arrays, other than those representing the data file , are declared using either the
Dim or
ReDim statement. The Dim statement (which must appear at the beginning of the program) declares an array with specific dimensions, e.g.:
Dim array1(4,6)
In this example, array1 is a two-dimensional array (matrix) with 4 rows and 6 columns. Matrices may have up to 8 dimensions, but most useful matrix functions will operate on one-dimensional arrays or vectors, or two-dimensional matrices.
The ReDim statement may be used to declare new arrays or change the size of previously-declared arrays (the number of dimensions must remain the same; e.g., you cannot re-dimension a two-dimensional array as a three-dimensional array). The array dimensions specified using ReDim may be dynamic, computed at the time of execution of the program, e.g.:
ReDim array2(NCases, NVars)
In this example, array2 is a two-dimensional array (matrix) with as many rows and columns as the respective number of cases and variables in the current data file.
For more information on using arrays, see Arrays in functions.
- Sizes of Matrices and Vectors
- All matrix functions can handle huge arrays, that is, arrays that are as large as your system permits; Statistica will allocate as much memory as possible given your system configuration. Thus, you can write programs for performing operations on extremely large matrices.
- Columns and Rows
- The program follows the standard convention for referencing the elements in two-dimensional matrices as Matrix(row,column). For example, the array declared as:
Dim array1(10,6);
has 10 rows and 6 columns.
- Matrix Functions
- Like all other functions in SVB, all matrix functions are accessible via the Function Browser. Because the program will automatically "remember" the dimensions of matrices, they do not have to be passed as arguments to the matrix functions, greatly simplifying the task of writing programs. For example:
This program will compute a correlation matrix (8 by 8) for a data file with 8 variables, and display it in a spreadsheet. For a complete list of matrix functions, see Statistica Visual Basic library of matrix functions.
- Memory Arrangement of Arrays
- Matrices are stored internally in memory by columns.