Here is the syntax of the function in SAS/IML
HADAMARD Function
returns a Hadamard matrix
HADAMARD( n, <, i>)
The inputs to the HADAMARD function are as follows:
n
specifies the order of the Hadamard matrix. Specify n such that n = 1, 2, or a multiple of 4 and any of the following hold:
n \le 256
n-1 is prime
(n / 2) - 1 is prime and n / 2 = 2\; {\rm mod}\; 4
n = 2 h, 4 h, 8 h, ..., 2^p h, where h is any n above
When any other n is specified, the HADAMARD function returns a zero.
i
specifies the row number to return. When i is not specified or i is negative, the full n x n matrix is returned.
The HADAMARD function returns a Hadamard matrix, which is an n x n matrix consisting entirely of the values 1 and - 1. The columns of a Hadamard matrix are all orthogonal. Hadamard matrices are frequently used to make orthogonal array experimental designs for two-level factors. For example, the following IML statements create a 12 x 12 Hadamard matrix:
h = hadamard(12);
print h[format=2.];
The results are as follows:
H
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
1 1 -1 1 -1 -1 -1 1 1 1 -1 1
1 1 1 -1 1 -1 -1 -1 1 1 1 -1
1 -1 1 1 -1 1 -1 -1 -1 1 1 1
1 1 -1 1 1 -1 1 -1 -1 -1 1 1
1 1 1 -1 1 1 -1 1 -1 -1 -1 1
1 1 1 1 -1 1 1 -1 1 -1 -1 -1
1 -1 1 1 1 -1 1 1 -1 1 -1 -1
1 -1 -1 1 1 1 -1 1 1 -1 1 -1
1 -1 -1 -1 1 1 1 -1 1 1 -1 1
1 1 -1 -1 -1 1 1 1 -1 1 1 -1
1 -1 1 -1 -1 -1 1 1 1 -1 1 1
The first column is an intercept and the next 11 columns form an orthogonal array experimental design for 11 two-level factors in 12 runs, 2^{11}.
To request the 17th row of a Hadamard matrix of order 448, use the following statement:
h = hadamard(448, 17);
|