|
NAG[g03bcc] NAG[nag_mv_procustes] - Procrustes rotations
|
|
Calling Sequence
g03bcc(stand, pscale, x, y, yhat, r, alpha, rss, res, 'n'=n, 'm'=m, 'tdx'=tdx, 'tdy'=tdy, 'tdr'=tdr, 'fail'=fail)
nag_mv_procustes(. . .)
Parameters
|
stand - String;
|
|
|
On entry: indicates if translation/normalization is required.
|
|
No translation or normalization.
|
|
Translation to the origin.
|
|
Translation to the origin and then to the centroid after rotation.
|
|
Unit normalization.
|
|
Translation and normalization.
|
|
Constraint: "Nag_NoTransNorm", "Nag_Orig", "Nag_OrigCentroid", "Nag_Norm", "Nag_OrigNorm" or "Nag_OrigNormCentroid". .
|
|
|
pscale - String;
|
|
|
On entry: indicates if least-squares scaling is applied after rotation.
|
|
Scaling is to be applied.
|
|
No scaling is applied.
|
|
Constraint: "Nag_LsqScale" or "Nag_NotLsqScale". .
|
|
|
x - Matrix(1..n, 1..tdx, datatype=float[8], order=C_order);
|
|
|
On entry: the matrix to be rotated, .
|
|
On exit: if , x will be unchanged.
|
|
If "Nag_Orig", "Nag_OrigCentroid", "Nag_OrigNorm" or "Nag_OrigNormCentroid", x will be translated to have zero column means.
|
|
If "Nag_Norm" or "Nag_OrigNorm", x will be scaled to have unit sum of squares.
|
|
If , x will be scaled to have the same sum of squares as y.
|
|
|
y - Matrix(1..n, 1..tdy, datatype=float[8], order=C_order);
|
|
|
On entry: the target matrix, .
|
|
On exit: if , then y will be unchanged.
|
|
If "Nag_Orig" or "Nag_OrigNorm", then y will be translated to have zero column means.
|
|
If "Nag_Norm" or "Nag_OrigNorm", then y will be scaled to have unit sum of squares.
|
|
If "Nag_OrigCentroid" or "Nag_OrigNormCentroid", then 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.
|
|
|
yhat - Matrix(1..n, 1..tdy, datatype=float[8], order=C_order);
|
|
|
On exit: the fitted matrix, .
|
|
|
r - Matrix(1..m, 1..tdr, datatype=float[8], order=C_order);
|
|
|
|
alpha - assignable;
|
|
|
Note: On exit the variable alpha will have a value of type float.
|
|
On exit: if the scaling factor, ; otherwise alpha is not set.
|
|
|
rss - assignable;
|
|
|
Note: On exit the variable rss will have a value of type float.
|
|
On exit: the residual sum of squares.
|
|
|
res - Vector(1..n, datatype=float[8]);
|
|
|
On exit: the residuals, , for .
|
|
|
'n'=n - integer; (optional)
|
|
|
Default value: the first dimension of the arrays x, y, yhat, res.
|
|
On entry: the number of points, .
|
|
Constraint: . .
|
|
|
'm'=m - integer; (optional)
|
|
|
Default value: the first dimension of the array r and the second dimension of the array rthe arrays x, y, yhat, r.
|
|
On entry: the number of dimensions, .
|
|
;
|
|
.
|
|
|
'tdx'=tdx - integer; (optional)
|
|
|
On entry: the second dimension of the array x as declared in the function from which nag_mv_procustes (g03bcc) is called.
|
|
Constraint: . .
|
|
|
'tdy'=tdy - integer; (optional)
|
|
|
On entry: the second dimension of the array y as declared in the function from which nag_mv_procustes (g03bcc) is called.
|
|
Constraint: . .
|
|
|
'tdr'=tdr - integer; (optional)
|
|
|
On entry: the second dimension of the array r as declared in the function from which nag_mv_procustes (g03bcc) is called.
|
|
Constraint: . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_mv_procustes (g03bcc) computes Procrustes rotations in which an orthogonal rotation is found so that a transformed matrix best matches a target matrix.
|
|
Description
|
|
Let and be by matrices. They can be considered as representing sets of points in an -dimensional space. The matrix may be a matrix of loadings from say factor or canonical variate analysis, and the 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 matrix is considered as the target matrix and the 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 and , i.e., the matrices will have zero column means. Then the rotation of the translated 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:
where and are orthogonal matrices and is a diagonal matrix. The matrix of rotations, , is computed as:
After rotation, a scaling or dilation factor, , may be estimated by least-squares. Thus, the final set of points that best match is given by:
Before rotation, both sets of points may be normalized to have unit sums of squares or the matrix may be normalized to have the same sum of squares as the matrix. After rotation, the results may be translated to the original centroid.
The th residual, , is given by the distance between the point given in the th row of and the point given in the th row of . The residual sum of squares is also computed.
|
|
Error Indicators and Warnings
|
|
"NE_2_INT_ARG_GT"
On entry, while . These arguments must satisfy .
"NE_ALLOC_FAIL"
Dynamic memory allocation failed.
"NE_BAD_PARAM"
On entry, argument stand had an illegal value.
"NE_INT_ARG_LT"
On entry, n must not be less than 1: .
"NE_INTERNAL_ERROR"
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please consult NAG for assistance.
"NE_LSQ_SCAL_ZERO_PTS"
The fitted matrix contains only zero-points when least-squares scaling is applied.
"NE_NORM_ZERO_PTS"
On entry, either x or y contains only zero-points (possibly after translation) when normalization is to be applied.
"NE_SVD_NOT_CONV"
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 f02wec (nag_real_svd) for further details.
|
|
|
Examples
|
|
>
|
stand := "Nag_OrigCentroid":
pscale := "Nag_LsqScale":
n := 3:
m := 2:
tdx := 2:
tdy := 2:
tdr := 2:
x := Matrix([[0.63, 0.58], [1.36, 0.39], [1.01, 1.76]], datatype=float[8], order='C_order'):
y := Matrix([[0, 0], [1, 0], [0, 2]], datatype=float[8], order='C_order'):
yhat := Matrix(3, 2, datatype=float[8], order='C_order'):
r := Matrix(2, 2, datatype=float[8], order='C_order'):
res := Vector(3, datatype=float[8]):
NAG:-g03bcc(stand, pscale, x, y, yhat, r, alpha, rss, res, 'n' = n, 'm' = m, 'tdx' = tdx, 'tdy' = tdy, 'tdr' = tdr):
|
|
|