Learn R Programming

GPArotation (version 2026.8-1)

Random.Start: Random Starting Matrix for Factor Rotation

Description

Generates a random orthogonal matrix for use as an initial rotation matrix (Tmat) in gradient projection rotation functions.

Usage

Random.Start(k = 2L)

Value

A \(k \times k\) orthogonal matrix drawn uniformly from the Haar measure on the orthogonal group O(k). Columns have unit length and are mutually orthogonal.

Arguments

k

a positive integer specifying the dimension of the square orthogonal matrix to generate (default 2).

Author

Coen A. Bernaards and Robert I. Jennrich with some R modifications by Paul Gilbert. Updated following a suggestion by Yves Rosseel.

Details

The function generates a random orthogonal matrix using QR decomposition of a matrix of standard normal variates, with a sign correction applied to the diagonal of R to ensure uniform sampling from the Haar measure. This follows the approach of Stewart (1980) and Mezzadri (2007).

The naive approach of qr.Q(qr(matrix(rnorm(k*k), k))) does not guarantee uniform sampling from the Haar measure. The sign correction Q %*% diag(sign(diag(R))) is required to achieve this. This was updated in GPArotation 2024.2-1 following a suggestion by Yves Rosseel.

For oblique rotation a random starting transformation matrix can be generated by normalizing the columns of a random matrix: X %*% diag(1/sqrt(diag(crossprod(X)))) where X <- matrix(rnorm(k*k), k).

References

Stewart, G.W. (1980). The efficient generation of random orthogonal matrices with an application to condition estimators. SIAM Journal on Numerical Analysis, 17(3), 403--409. tools:::Rd_expr_doi("10.1137/0717034")

Mezzadri, F. (2007) How to generate random matrices from the classical compact groups. Notices of the American Mathematical Society, 54(5), 592--604. arXiv:math-ph/0609050

See Also

GPFRSorth, GPFRSoblq, GPForth, GPFoblq, rotations

Examples

Run this code
  # Generate a 5 x 5 random orthogonal matrix
  Random.Start(5)

  # Generate a random orthogonal start matrix
  Q <- Random.Start(4)

  # Verify orthogonality: t(Q) %*% Q should equal the identity matrix
  stopifnot(isTRUE(all.equal(t(Q) %*% Q, diag(4), tolerance = 1e-10)))
  
  # Use as starting matrix for rotation
  data("Thurstone", package = "GPArotation")
  simplimax(box26, Tmat = Random.Start(3))

Run the code above in your browser using DataLab