# Generate a random ortogonal matrix of dimension 5 x 5
  Random.Start(5)
  
  # function for generating orthogonal or oblique random matrix
  Random.Start <- function(k = 2L,orthogonal=TRUE){
    mat <- matrix(rnorm(k*k),k)
    if (orthogonal){
      qr.out <- qr(matrix(rnorm(k * k), nrow = k, ncol = k))
      Q <- qr.Q(qr.out)
      R <- qr.R(qr.out)
      R.diag <- diag(R)
      R.diag2 <- R.diag/abs(R.diag)
      ans <- t(t(Q) * R.diag2)
      ans
      }
    else{
	  ans <- mat %*% diag(1/sqrt(diag(crossprod(mat))))
 	  }
    ans
    }
    	
  data("Thurstone", package="GPArotation")
  simplimax(box26,Tmat = Random.Start(3, orthogonal = TRUE))
  simplimax(box26,Tmat = Random.Start(3, orthogonal = FALSE))
  # covariance matrix is Phi = t(Th) %*% Th
  rms <- Random.Start(3, FALSE)
  t(rms) %*% rms # covariance matrix because oblique rms
  rms <- Random.Start(3, TRUE)
  t(rms) %*% rms # identity matrix because orthogonal rms
	
   Run the code above in your browser using DataLab