hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_mv_rot_procrustes (g03bc)

Purpose

nag_mv_rot_procrustes (g03bc) computes Procrustes rotations in which an orthogonal rotation is found so that a transformed matrix best matches a target matrix.

Syntax

[x, y, yhat, r, alpha, rss, res, ifail] = g03bc(stand, pscale, x, y, 'n', n, 'm', m)
[x, y, yhat, r, alpha, rss, res, ifail] = nag_mv_rot_procrustes(stand, pscale, x, y, 'n', n, 'm', m)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 22: n has been made optional
.

Description

Let XX and YY be nn by mm matrices. They can be considered as representing sets of nn points in an mm-dimensional space. The XX matrix may be a matrix of loadings from say factor or canonical variate analysis, and the YY matrix may be a postulated pattern matrix or the loadings from a different sample. The problem is to relate the two sets of points without disturbing the relationships between the points in each set. This can be achieved by translating, rotating and scaling the sets of points. The YY matrix is considered as the target matrix and the XX matrix is rotated to match that matrix.
First the two sets of points are translated so that their centroids are at the origin to give XcXc and YcYc, i.e., the matrices will have zero column means. Then the rotation of the translated XcXc matrix which minimizes the sum of squared distances between corresponding points in the two sets is found. This is computed from the singular value decomposition of the matrix:
XcTYc = UDVT,
XcTYc=UDVT,
where UU and VV are orthogonal matrices and DD is a diagonal matrix. The matrix of rotations, RR, is computed as:
R = UVT.
R=UVT.
After rotation, a scaling or dilation factor, αα, may be estimated by least squares. Thus, the final set of points that best match YcYc is given by:
c = αXcR.
Y^c=αXcR.
Before rotation, both sets of points may be normalized to have unit sums of squares or the XX matrix may be normalized to have the same sum of squares as the YY matrix. After rotation, the results may be translated to the original YY centroid.
The iith residual, riri, is given by the distance between the point given in the iith row of YY and the point given in the iith row of Y^. The residual sum of squares is also computed.

References

Krzanowski W J (1990) Principles of Multivariate Analysis Oxford University Press
Lawley D N and Maxwell A E (1971) Factor Analysis as a Statistical Method (2nd Edition) Butterworths

Parameters

Compulsory Input Parameters

1:     stand – string (length ≥ 1)
Indicates if translation/normalization is required.
stand = 'N'stand='N'
There is no translation or normalization.
stand = 'Z'stand='Z'
There is translation to the origin (i.e., to zero).
stand = 'C'stand='C'
There is translation to origin and then to the YY centroid after rotation.
stand = 'U'stand='U'
There is unit normalization.
stand = 'S'stand='S'
There is translation and normalization (i.e., there is standardization).
stand = 'M'stand='M'
There is translation and normalization to YY scale, then translation to the YY centroid after rotation (i.e., they are matched).
Constraint: stand = 'N'stand='N', 'Z''Z', 'C''C', 'U''U', 'S''S' or 'M''M'.
2:     pscale – string (length ≥ 1)
Indicates if least squares scaling is to be applied after rotation.
pscale = 'S'pscale='S'
Scaling is applied.
pscale = 'U'pscale='U'
No scaling is applied.
Constraint: pscale = 'S'pscale='S' or 'U''U'.
3:     x(ldx,m) – double array
ldx, the first dimension of the array, must satisfy the constraint ldxnldxn.
XX, the matrix to be rotated.
4:     y(ldy,m) – double array
ldy, the first dimension of the array, must satisfy the constraint ldynldyn.
The target matrix, yy.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the arrays x, y. (An error is raised if these dimensions are not equal.)
nn, the number of points.
Constraint: nmnm.
2:     m – int64int32nag_int scalar
Default: The second dimension of the arrays x, y. (An error is raised if these dimensions are not equal.)
mm, the number of dimensions.
Constraint: m1m1.

Input Parameters Omitted from the MATLAB Interface

ldx ldy ldr wk

Output Parameters

1:     x(ldx,m) – double array
ldxnldxn.
If stand = 'N'stand='N', x will be unchanged.
If stand = 'Z'stand='Z', 'C''C', 'S''S' or 'M''M', x will be translated to have zero column means.
If stand = 'U'stand='U' or 'S''S', x will be scaled to have unit sum of squares.
If stand = 'M'stand='M', x will be scaled to have the same sum of squares as y.
2:     y(ldy,m) – double array
ldynldyn.
If stand = 'N'stand='N', y will be unchanged.
If stand = 'Z'stand='Z' or 'S''S', y will be translated to have zero column means.
If stand = 'U'stand='U' or 'S''S', y will be scaled to have unit sum of squares.
If stand = 'C'stand='C' or 'M''M', y will be translated and then after rotation translated back. The output y should be the same as the input y except for rounding errors.
3:     yhat(ldy,m) – double array
ldynldyn.
The fitted matrix, Y^.
4:     r(ldr,m) – double array
ldrmldrm.
The matrix of rotations, RR, see Section [Further Comments].
5:     alpha – double scalar
If pscale = 'S'pscale='S' the scaling factor, αα; otherwise alpha is not set.
6:     rss – double scalar
The residual sum of squares.
7:     res(n) – double array
The residuals, riri, for i = 1,2,,ni=1,2,,n.
8:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,n < mn<m,
orm < 1m<1,
orldx < nldx<n,
orldy < nldy<n,
orldr < mldr<m,
orstand'N'stand'N', 'Z''Z', 'C''C', 'U''U', 'S''S' or 'M''M',
orpscale'S'pscale'S' or 'U''U'.
  ifail = 2ifail=2
On entry, either x or y contain only zero-points (possibly after translation) when normalization is to be applied.
  ifail = 3ifail=3
The Y^ matrix contains only zero-points when least squares scaling is applied.
  ifail = 4ifail=4
The singular value decomposition has failed to converge. This is an unlikely error exit.

Accuracy

The accuracy of the calculation of the rotation matrix largely depends upon the singular value decomposition. See the F08 Chapter Introduction for further details.

Further Comments

Note that if the matrix XcTYXcTY is not of full rank, then the matrix of rotations, RR, may not be unique even if there is a unique solution in terms of the rotated matrix, cY^c. The matrix RR may also include reflections as well as pure rotations, see Krzanowski (1990).
If the column dimensions of the XX and YY matrices are not equal, the smaller of the two should be supplemented by columns of zeros. Adding a column of zeros to both XX and YY will have the effect of allowing reflections as well as rotations.

Example

function nag_mv_rot_procrustes_example
stand = 'c';
pscale = 's';
x = [0.63, 0.58;
     1.36, 0.39;
     1.01, 1.76];
y = [0, 0;
     1, 0;
     0, 2];
[xOut, yOut, yhat, r, alpha, rss, res, ifail] = nag_mv_rot_procrustes(stand, pscale, x, y)
 

xOut =

   -0.3700   -0.3300
    0.3600   -0.5200
    0.0100    0.8500


yOut =

     0     0
     1     0
     0     2


yhat =

   -0.0934    0.0239
    1.0805    0.0259
    0.0130    1.9502


r =

    0.9673    0.2536
   -0.2536    0.9673


alpha =

    1.5563


rss =

    0.0191


res =

    0.0964
    0.0846
    0.0514


ifail =

                    0


function g03bc_example
stand = 'c';
pscale = 's';
x = [0.63, 0.58;
     1.36, 0.39;
     1.01, 1.76];
y = [0, 0;
     1, 0;
     0, 2];
[xOut, yOut, yhat, r, alpha, rss, res, ifail] = g03bc(stand, pscale, x, y)
 

xOut =

   -0.3700   -0.3300
    0.3600   -0.5200
    0.0100    0.8500


yOut =

     0     0
     1     0
     0     2


yhat =

   -0.0934    0.0239
    1.0805    0.0259
    0.0130    1.9502


r =

    0.9673    0.2536
   -0.2536    0.9673


alpha =

    1.5563


rss =

    0.0191


res =

    0.0964
    0.0846
    0.0514


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013