R Under development (unstable) (2024-02-02 r85855 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > # Also see the first test in rotations.R > # compares varimax to Varimax to 0.001 discrepancy > > Sys.getenv("R_LIBS") [1] "D:\\temp\\RtmpO4cY16\\RLIBS_2b7c074005b36" > library() > require("GPArotation") Loading required package: GPArotation > search() [1] ".GlobalEnv" "package:GPArotation" "package:stats" [4] "package:graphics" "package:grDevices" "package:utils" [7] "package:datasets" "package:methods" "Autoloads" [10] "package:base" > Sys.info() sysname release version nodename machine "Windows" "Server x64" "build 20348" "CRANWIN3" "x86-64" login user effective_user "CRAN" "CRAN" "CRAN" > > ### note that this is a slightly lower bar than other tests > ### to correct for the built-in varimax function working differently > ### than GPA, and to ensure Varimax convergence > ### these are differences in the 4th decimal or better > fuzz <- 1e-4 > ### > all.ok <- TRUE > > sortFac <- function(x){ # Based on Fungible faSort + vx <- order(colSums(x$loadings^2), decreasing = TRUE) + Dsgn <- diag(sign(colSums(x$loadings^3))) [ , vx] + x$Th <- x$Th %*% Dsgn + x$loadings <- x$loadings %*% Dsgn + if ("Phi" %in% names(x)) { + x$Phi <- diag(1/diag(Dsgn)) %*% x$Phi %*% Dsgn + } + x + } > data(Thurstone, package="GPArotation") > yv1 <- varimax(box20, normalize = FALSE, eps = 1e-7) #built-in R > names(yv1) <- c("loadings","Th") > yv1 <- sortFac(yv1) > yv2 <- sortFac(Varimax(box20, normalize = FALSE, maxit = 10000, eps = 1e-7)) #GPArotation version > # yv.diff <- unclass(yv1$loadings) - unclass(yv2$loadings) > # max(abs(yv.diff)) > > > if( fuzz < max(abs(yv1$loadings - yv2$loadings))) { + cat("Calculated varimax is not the same as Varimax:\n") + # print(yv2$loadings, digits=18) + cat("difference:\n") + print(yv1$loadings - yv2$loadings, digits=18) + all.ok <- FALSE + } > > > proc.time() user system elapsed 0.18 0.09 0.26