Learn R Programming

bigutilsr (version 0.3.11)

varimax2: Varimax rotation

Description

Varimax rotation

Usage

varimax2(X, normalize = FALSE, reorder = TRUE, rotmat = FALSE)

Value

Either the rotation matrix rot, or the rotated matrix X %*% rot, depending on rotmat.

Arguments

X

A matrix with more rows than columns.

normalize

Whether to apply Kaiser normalization? See stats::varimax. Default is FALSE.

reorder

Whether to permute rotation vectors to maximize the conservation of the order of the initial columns of X. Default is TRUE.

rotmat

Whether to return the rotation matrix rot, or the rotated matrix X %*% rot (the default, FALSE).

Examples

Run this code
X <- as.matrix(iris[1:4])
X_rot <- varimax2(X)
X_rot2 <- varimax(X, normalize = FALSE)$loadings[]
all.equal(X_rot2, X_rot[, c(3, 2, 1, 4)], check.attributes = FALSE)
varimax2(X, rotmat = TRUE)

X2 <- prcomp(X)$x
X2_rot <- varimax2(X2)
X2_rot2 <- varimax(X2, normalize = FALSE)$loadings[]
all.equal(X2_rot, X2_rot2, check.attributes = FALSE)

Run the code above in your browser using DataLab