Language Reference

HDIR Function

performs a horizontal direct product

HDIR( matrix1, matrix2)

where matrix1 and matrix2 are numeric matrices or literals.

The HDIR function performs a direct product on all rows of matrix1 and matrix2 and creates a new matrix by stacking these row vectors into a matrix. This operation is useful in constructing design matrices of interaction effects. The matrix1 and matrix2 arguments must have the same number of rows. The result has the same number of rows as matrix1 and matrix2. The number of columns is equal to the product of the number of columns in matrix1 and matrix2.

For example, the following statements produce the matrix c, as shown:

  
    a={1 2, 
       2 4, 
       3 6}; 
    b={0  2, 
       1  1, 
       0 -1}; 
    c=hdir(a,b);
 

  
           C             3 rows      4 cols    (numeric) 
  
                           0         2         0         4 
                           2         2         4         4 
                           0        -3         0        -6
 
The HDIR function is useful for constructing crossed and nested effects from main-effect design matrices in ANOVA models.

Previous Page | Next Page | Top of Page