GINV Function

GINV( matrix ) ;

The GINV function computes the Moore-Penrose generalized inverse of matrix. This inverse, known as the four-condition inverse, has these properties:

If then

     

The generalized inverse is also known as the pseudoinverse, usually denoted by . It is computed by using the singular value decomposition (Wilkinson and Reinsch; 1971).

See Rao and Mitra (1971) for a discussion of properties of this function.

As an example, consider the following model:

     

Least squares regression for this model can be performed by using the quantity ginv(x)*y as the estimate of . This solution has minimum among all solutions that minimize , where .

Projection matrices can be formed by specifying GINV (row space) or GINV (column space).

The following program demonstrates some common uses of the GINV function:

A = {1 0 1 0 0,
     1 0 0 1 0,
     1 0 0 0 1,
     0 1 1 0 0,
     0 1 0 1 0,
     0 1 0 0 1 };

/* find generalized inverse */
Ainv = ginv(A);

/* find LS solution: min  |Ax-b|^2 */
b = { 3, 2, 4, 2, 1, 3 };
x = Ainv*b;

/* form projection matrix onto row space.
   Note P = P` and P*P = P */
P = Ainv*A;

/* find numerical rank of A */
rankA = round(trace(P));

reset fuzz;
print Ainv, rankA, x, P;

Figure 23.123 Common Uses of the Generized Inverse
Ainv
0.2666667 0.2666667 0.2666667 -0.066667 -0.066667 -0.066667
-0.066667 -0.066667 -0.066667 0.2666667 0.2666667 0.2666667
0.4 -0.1 -0.1 0.4 -0.1 -0.1
-0.1 0.4 -0.1 -0.1 0.4 -0.1
-0.1 -0.1 0.4 -0.1 -0.1 0.4

rankA
4

x
2
1
1
0
2

P
0.8 -0.2 0.2 0.2 0.2
-0.2 0.8 0.2 0.2 0.2
0.2 0.2 0.8 -0.2 -0.2
0.2 0.2 -0.2 0.8 -0.2
0.2 0.2 -0.2 -0.2 0.8

If is an matrix, then, in addition to the memory allocated for the return matrix, the GINV function temporarily allocates an array for performing its computation.