1. Home
2. SYMMETRICMATRIX directive

# SYMMETRICMATRIX directive

Declares one or more symmetric matrix data structures.

### Options

`ROWS` = scalar, vector or pointer or text Number of rows, or labels for rows (and columns); default `*` Values for all the symmetric matrices; default `*` Whether to modify (instead of redefining) existing structures (`yes, no`); default `no` Information to be used by default to identify the symmetric matrices in output (`identifier`, `extra`); if this is not set, they will be identified in the standard way for each type of output

### Parameters

`IDENTIFIER` = identifiers Identifiers of the symmetric matrices Values for each symmetric matrix Number of decimal places for printing Extra text associated with each identifier Minimum value for the contents of each structure Maximum value for the contents of each structure Default format to use when the contents represent dates and times

### Description

A symmetric square matrix is symmetric about its leading diagonal: that is, the value in column i of row j is the same as that in column j of row i. For example:

`1 2 3`

`2 1 4`

`3 4 1`

Symmetric matrices often occur in statistics. Suppose, for example, that we have n random variables X1Xn. Then the covariance of Xi with Xj is the same as the covariance of Xj with Xi. The covariance matrix of the random variables is therefore symmetric: the off-diagonal elements of the matrix are the covariances (and the diagonal elements are the variances).

Because of this symmetry, Genstat stores only the diagonal elements and those below it; this is called the lower triangle. So you must specify only these values, whether in the declaration by `SSPM` or in a `READ` statement. (As always, you give them in row order: so if there are n rows, then for the first you supply one value, for the second two, and so on.) Likewise, Genstat prints only the lower triangle in output, for example with `PRINT`.

The `ROWS` option defines both the number of rows and the number of columns. The simplest way of doing this is to use a scalar to define the number of rows and columns explicitly. Alternatively, you can set `ROWS` to a variate, text or pointer, whose length then defines the number of rows and whose values will then be used as labels, for example when the symmetric matrix is printed. Finally, if you specify a factor, the number of levels defines the number of rows and the labels if available, or otherwise the levels, are used for labelling.

Values can be assigned to the symmetric matrices by either the `VALUES` option or the `VALUES` parameter. The option defines a common value for all the matrices in the declaration, while the parameter allows them each to be given a different value. If both the option and the parameter are specified, the parameter takes precedence.

If the `MODIFY` option is set to `yes` any existing attributes and values of the symmetric matrices are retained (if still appropriate); otherwise these are lost.

The `DECIMALS` parameter allows you to define a number of decimal places to be used by default when each symmetric matrix is printed. You can associate a text of extra annotation with each symmetric matrix using the `EXTRA` parameter. The `MINIMUM` and `MAXIMUM` parameters allow you to define lower and upper limits on the values in each symmetric matrix. Genstat then prints warnings if any values outside that range are allocated to the matrix. The `DREPRESENTATION` parameter allows a scalar or a single-valued text to be specified for each symmetric matrix to indicate that the matrix stores dates and times, and to define a format to be used for these, by default, when they are printed; details are given in the description of the `PRINT` directive.

The `IPRINT` option can be set to specify how the symmetric matrices will be identified in output. If `IPRINT` is not set, they will be identified in whatever way is usual for the section of output concerned. For example, the `PRINT` directive generally uses their identifiers (although this can be changed using the `IPRINT` option of `PRINT` itself).

Options: `ROWS`, `VALUES`, `MODIFY`, `IPRINT`.

Parameters: `IDENTIFIER`, `VALUES`, `DECIMALS`, `EXTRA`, `MINIMUM`, `MAXIMUM`, `DREPRESENTATION`.

### See also

Directives: `DIAGONALMATRIX`, `LRV`, `MATRIX`, `SSPM`.

Commands for: Data structures.

### Example

```" Example SYMM-1: declaring a symmetric matrix"
VARIATE Weight,Height,Reach
POINTER [VALUES=Weight,Height,Reach] Vars
SYMMETRICMATRIX [ROWS=Vars; VALUES=1.0,0.68,1.0,0.43,0.72,1.0] Correl
PRINT Correl
```
Updated on June 18, 2019