R Under development (unstable) (2024-02-29 r86017 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. > # testing that the print.GPArotation output is identical > # for 2 runs of quartimin rotation, that have 2 > # different looking loadings matrices wrt sign and order > # the print.GPArotation should look identical > > > Sys.getenv("R_LIBS") [1] "D:\\temp\\Rtmpqiwotp\\RLIBS_256f87557c21" > 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" > > require("stats") > require("GPArotation") > > athl <- matrix(c( + .73, -.07, .50, .82, -.01, .27, .77, -.46, -.22, .78, .17, .03, + .77, .41, .13, .81, -.01, .27, .71, -.45, -.30, .82, .12, -.11, + .66, -.15, -.45, .39, .76, -.40), byrow=T, ncol =3) > ## z1 gives the results that have the right ordering and sign of the factors > ## z2 is a random other order and sign > set.seed(238) > z1 <- quartimin(athl, Tmat = Random.Start(3)) > head(z1$loadings) [,1] [,2] [,3] [1,] -0.9451409 0.05346419 0.180327102 [2,] -0.7725340 -0.14313505 -0.011868009 [3,] -0.1322889 -0.86168891 0.128470606 [4,] -0.5377313 -0.20500970 -0.287529554 [5,] -0.6888492 0.05547964 -0.440716643 [6,] -0.7665208 -0.13863386 -0.009868994 > set.seed(46) > z2 <- quartimin(athl, Tmat = Random.Start(3)) > head(z2$loadings) [,1] [,2] [,3] [1,] -0.9451416 -0.180326159 0.05346510 [2,] -0.7725340 0.011869079 -0.14313424 [3,] -0.1322881 -0.128469679 -0.86168934 [4,] -0.5377307 0.287530600 -0.20500891 [5,] -0.6888486 0.440717717 0.05548088 [6,] -0.7665208 0.009870051 -0.13863307 > > # WITHOUT SORTING > all.ok <- TRUE > # are z1 and z2 loadings different? Test at the 5th decimal > # if tst = T then there are differences (good). if tst = F then no differences (bad) > tst <- max(z1$loadings - z2$loadings) > 1e-5 > if (! tst) { all.ok <- F} > # rotation matrix > tst <- max(z1$Th - z2$Th) > 1e-5 > if (! tst) { all.ok <- F} > # correlation matrix > tst <- max(z1$Phi - z2$Phi) > 1e-5 > if (! tst) { all.ok <- F} > > if (! all.ok) stop("some tests FAILED before sorting") > > > # NOW WE SORT: z1 to z1s and z2 to z2s > z1s <- print(z1, sortLoadings = TRUE, rotateMat = TRUE, Table = TRUE) Oblique rotation method Quartimin converged. Loadings: [,1] [,2] [,3] [1,] 0.9451 -0.0535 -0.18033 [2,] 0.7725 0.1431 0.01187 [3,] 0.1323 0.8617 -0.12847 [4,] 0.5377 0.2050 0.28753 [5,] 0.6888 -0.0555 0.44072 [6,] 0.7665 0.1386 0.00987 [7,] 0.0150 0.8967 -0.08931 [8,] 0.4047 0.3792 0.32647 [9,] -0.1056 0.7915 0.24071 [10,] -0.0155 -0.0165 0.94994 [,1] [,2] [,3] SS loadings 3.374 2.675 1.528 Proportion Var 0.337 0.268 0.153 Cumulative Var 0.337 0.605 0.758 Phi: [,1] [,2] [,3] [1,] 1.000 0.554 0.259 [2,] 0.554 1.000 0.186 [3,] 0.259 0.186 1.000 Rotating matrix: [,1] [,2] [,3] [1,] 0.601 0.450 0.200 [2,] 0.220 -0.707 0.868 [3,] 1.043 -0.863 -0.531 Iteration table: iter f log10(s) alpha [1,] 0 0.641 0.0671 1.000 [2,] 1 0.528 -0.3459 0.125 [3,] 2 0.500 -0.7144 0.250 [4,] 3 0.483 -0.6656 0.500 [5,] 4 0.452 -0.3927 1.000 [6,] 5 0.430 -0.6116 0.250 [7,] 6 0.406 -0.5591 0.500 [8,] 7 0.380 -0.5007 0.500 [9,] 8 0.350 -0.4382 0.500 [10,] 9 0.326 -0.5634 0.250 [11,] 10 0.289 -0.5615 0.500 [12,] 11 0.223 -0.6139 1.000 [13,] 12 0.185 -0.6265 1.000 [14,] 13 0.171 -0.8657 0.500 [15,] 14 0.165 -1.1075 0.500 [16,] 15 0.163 -1.2994 0.500 [17,] 16 0.162 -1.4865 0.500 [18,] 17 0.161 -1.6643 0.500 [19,] 18 0.161 -1.8373 0.500 [20,] 19 0.161 -1.8981 1.000 [21,] 20 0.161 -2.3175 0.250 [22,] 21 0.161 -2.4862 0.500 [23,] 22 0.161 -2.6521 0.500 [24,] 23 0.161 -2.8163 0.500 [25,] 24 0.161 -2.8540 1.000 [26,] 25 0.161 -3.2855 0.250 [27,] 26 0.161 -3.4503 0.500 [28,] 27 0.161 -3.6136 0.500 [29,] 28 0.161 -3.7757 0.500 [30,] 29 0.161 -3.8078 1.000 [31,] 30 0.161 -4.2454 0.250 [32,] 31 0.161 -4.4084 0.500 [33,] 32 0.161 -4.5704 0.500 [34,] 33 0.161 -4.7318 0.500 [35,] 34 0.161 -4.7541 1.000 [36,] 35 0.161 -5.2020 0.250 > z2s <- print(z2, sortLoadings = TRUE, rotateMat = TRUE, Table = TRUE) Oblique rotation method Quartimin converged. Loadings: [,1] [,2] [,3] [1,] 0.9451 -0.0535 -0.18033 [2,] 0.7725 0.1431 0.01187 [3,] 0.1323 0.8617 -0.12847 [4,] 0.5377 0.2050 0.28753 [5,] 0.6888 -0.0555 0.44072 [6,] 0.7665 0.1386 0.00987 [7,] 0.0150 0.8967 -0.08930 [8,] 0.4047 0.3792 0.32647 [9,] -0.1056 0.7915 0.24071 [10,] -0.0155 -0.0165 0.94994 [,1] [,2] [,3] SS loadings 3.374 2.675 1.528 Proportion Var 0.337 0.268 0.153 Cumulative Var 0.337 0.605 0.758 Phi: [,1] [,2] [,3] [1,] 1.000 0.554 0.259 [2,] 0.554 1.000 0.186 [3,] 0.259 0.186 1.000 Rotating matrix: [,1] [,2] [,3] [1,] 0.601 0.450 0.200 [2,] 0.220 -0.707 0.868 [3,] 1.043 -0.863 -0.531 Iteration table: iter f log10(s) alpha [1,] 0 0.513 0.159 1.000 [2,] 1 0.338 -0.187 0.125 [3,] 2 0.263 -0.455 0.250 [4,] 3 0.214 -0.568 0.500 [5,] 4 0.172 -0.726 1.000 [6,] 5 0.165 -1.001 0.250 [7,] 6 0.162 -1.334 0.500 [8,] 7 0.161 -1.612 0.500 [9,] 8 0.161 -1.840 0.500 [10,] 9 0.161 -2.031 0.500 [11,] 10 0.161 -2.208 0.500 [12,] 11 0.161 -2.377 0.500 [13,] 12 0.161 -2.419 1.000 [14,] 13 0.161 -2.848 0.250 [15,] 14 0.161 -3.016 0.500 [16,] 15 0.161 -3.182 0.500 [17,] 16 0.161 -3.214 1.000 [18,] 17 0.161 -3.647 0.250 [19,] 18 0.161 -3.814 0.500 [20,] 19 0.161 -3.979 0.500 [21,] 20 0.161 -4.143 0.500 [22,] 21 0.161 -4.182 1.000 [23,] 22 0.161 -4.611 0.250 [24,] 23 0.161 -4.775 0.500 [25,] 24 0.161 -4.938 0.500 [26,] 25 0.161 -5.100 0.500 > all.ok <- TRUE > # are z1 and z2 loadings different? Test at the 5th decimal > # if tst = T then there are differences (bad). if tst = F then no differences (good) > tst <- max(z1s$loadings - z2s$loadings) > 1e-5 > if (tst) { all.ok <- F} > # rotation matrix > tst <- max(z1s$Th - z2s$Th) > 1e-5 > if (tst) { all.ok <- F} > # correlation matrix > tst <- max(z1s$Phi - z2s$Phi) > 1e-5 > if (tst) { all.ok <- F} > > if (! all.ok) stop("some tests FAILED after sorting") > > #> z1 > #Oblique rotation method Quartimin converged. > #Loadings: > # [,1] [,2] [,3] > # [1,] 0.9451 -0.0535 -0.18033 > # [2,] 0.7725 0.1431 0.01187 > # [3,] 0.1323 0.8617 -0.12847 > # [4,] 0.5377 0.2050 0.28753 > # [5,] 0.6888 -0.0555 0.44072 > # [6,] 0.7665 0.1386 0.00987 > # [7,] 0.0150 0.8967 -0.08931 > # [8,] 0.4047 0.3792 0.32647 > # [9,] -0.1056 0.7915 0.24071 > #[10,] -0.0155 -0.0165 0.94994 > # > # [,1] [,2] [,3] > #SS loadings 3.034 2.405 1.401 > #Proportion Var 0.303 0.240 0.140 > #Cumulative Var 0.303 0.544 0.684 > # > #Phi: > # [,1] [,2] [,3] > #[1,] 1.000 0.554 0.259 > #[2,] 0.554 1.000 0.186 > #[3,] 0.259 0.186 1.000 > #> z2 > #Oblique rotation method Quartimin converged. > #Loadings: > # [,1] [,2] [,3] > # [1,] 0.9451 -0.0535 -0.18033 > # [2,] 0.7725 0.1431 0.01187 > # [3,] 0.1323 0.8617 -0.12847 > # [4,] 0.5377 0.2050 0.28753 > # [5,] 0.6888 -0.0555 0.44072 > # [6,] 0.7665 0.1386 0.00987 > # [7,] 0.0150 0.8967 -0.08930 > # [8,] 0.4047 0.3792 0.32647 > # [9,] -0.1056 0.7915 0.24071 > #[10,] -0.0155 -0.0165 0.94994 > # > # [,1] [,2] [,3] > #SS loadings 3.034 2.405 1.401 > #Proportion Var 0.303 0.240 0.140 > #Cumulative Var 0.303 0.544 0.684 > # > #Phi: > # [,1] [,2] [,3] > #[1,] 1.000 0.554 0.259 > #[2,] 0.554 1.000 0.186 > #[3,] 0.259 0.186 1.000 > > > ########################################################## > # RUNNING A PRINT WITHOUT ERRORS > ########################################################## > # data(ability.cov) > # L <- loadings(factanal(factors = 2, covmat=ability.cov)) > # > #v <- GPFRSoblq(L, eps = 1e-7, method = "oblimin", methodArgs = list(gam = .5), randomStarts = 100) > #GPArotation:::print.GPArotation(v, rotateMat = T, Table = T) > #print(v, rotateMat = T, Table = T) > # > #GPArotation:::summary.GPArotation(v) > #summary(v) > > > > proc.time() user system elapsed 0.15 0.06 0.21