naginterfaces.library.mv.rot_procrustes¶
- naginterfaces.library.mv.rot_procrustes(stand, pscale, x, y)[source]¶
rot_procrustes
computes Procrustes rotations in which an orthogonal rotation is found so that a transformed matrix best matches a target matrix.For full information please refer to the NAG Library document for g03bc
https://www.nag.com/numeric/nl/nagdoc_29/flhtml/g03/g03bcf.html
- Parameters
- standstr, length 1
Indicates if translation/normalization is required.
There is no translation or normalization.
There is translation to the origin (i.e., to zero).
There is translation to origin and then to the centroid after rotation.
There is unit normalization.
There is translation and normalization (i.e., there is standardization).
There is translation and normalization to scale, then translation to the centroid after rotation (i.e., they are matched).
- pscalestr, length 1
Indicates if least squares scaling is to be applied after rotation.
Scaling is applied.
No scaling is applied.
- xfloat, array-like, shape
, the matrix to be rotated.
- yfloat, array-like, shape
The target matrix, .
- Returns
- xfloat, ndarray, shape
If , will be unchanged.
If , , or , will be translated to have zero column means.
If or , will be scaled to have unit sum of squares.
If , will be scaled to have the same sum of squares as .
- yfloat, ndarray, shape
If , will be unchanged.
If or , will be translated to have zero column means.
If or , will be scaled to have unit sum of squares.
If or , will be translated and then after rotation translated back.
The output should be the same as the input except for rounding errors.
- yhatfloat, ndarray, shape
The fitted matrix, .
- rfloat, ndarray, shape
The matrix of rotations, , see Further Comments.
- alphafloat
If the scaling factor, ; otherwise is not set.
- rssfloat
The residual sum of squares.
- resfloat, ndarray, shape
The residuals, , for .
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: or .
- (errno )
On entry, .
Constraint: , , , , or .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, and .
Constraint: .
- (errno )
Only one distinct point (centred at zero) in array.
- (errno )
Only one distinct point (centred at zero) in array.
- (errno )
contains only zero-points when least squares scaling is applied.
- (errno )
The singular value decomposition has failed to converge.
- Notes
In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.
Let and be 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.
- 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