R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 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 a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("GPArotation-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('GPArotation') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "GPA" > > ### * GPA > > flush(stderr()); flush(stdout()) > > ### Name: GPA > ### Title: Rotation optimization > ### Aliases: GPForth GPFoblq > ### Keywords: multivariate > > ### ** Examples > > data("Harman", package="GPArotation") > qHarman <- GPForth(Harman8, Tmat=diag(2), method="quartimax") > > data("WansbeekMeijer", package="GPArotation") > fa.unrotated <- factanal(factors = 2, covmat=NetherlandsTV, + normalize=TRUE, rotation="none") > > GPForth(loadings(fa.unrotated), method="varimax", normalize=TRUE)$Lh Factor1 Factor2 NL1 0.2296980 -0.7570052 TV2 0.3254766 -0.7745330 NL3 0.2279537 -0.7388609 RTL4 0.6348515 -0.2998743 RTL5 0.7073135 -0.2782447 Veronica 0.7893605 -0.2141181 SBS6 0.6988858 -0.1990791 > > TV <- GPFoblq(loadings(fa.unrotated), method="oblimin", normalize=TRUE) > > print(TV) Oblique rotation method Oblimin Quartimin converged. Loadings: Factor1 Factor2 NL1 -0.0245 -0.8055 TV2 0.0822 -0.7884 NL3 -0.0194 -0.7847 RTL4 0.6350 -0.1038 RTL5 0.7294 -0.0495 Veronica 0.8518 0.0589 SBS6 0.7504 0.0409 Rotating matrix: [,1] [,2] [1,] 0.562 -0.556 [2,] 1.115 1.118 Phi: [,1] [,2] [1,] 1.000 -0.599 [2,] -0.599 1.000 > print(TV, Table=TRUE) Oblique rotation method Oblimin Quartimin converged. Loadings: Factor1 Factor2 NL1 -0.0245 -0.8055 TV2 0.0822 -0.7884 NL3 -0.0194 -0.7847 RTL4 0.6350 -0.1038 RTL5 0.7294 -0.0495 Veronica 0.8518 0.0589 SBS6 0.7504 0.0409 Rotating matrix: [,1] [,2] [1,] 0.562 -0.556 [2,] 1.115 1.118 Phi: [,1] [,2] [1,] 1.000 -0.599 [2,] -0.599 1.000 Iteration table: [,1] [,2] [,3] [,4] [1,] 0 0.5335 -0.52594 1.000 [2,] 1 0.5274 -0.95379 0.125 [3,] 2 0.5239 -0.83755 0.250 [4,] 3 0.5103 -0.63500 0.500 [5,] 4 0.4332 -0.32908 1.000 [6,] 5 0.2767 -0.00785 1.000 [7,] 6 0.1404 -0.23170 0.250 [8,] 7 0.0539 -0.33988 0.500 [9,] 8 0.0214 -1.05883 0.250 [10,] 9 0.0206 -1.36695 0.125 [11,] 10 0.0205 -1.69920 0.125 [12,] 11 0.0204 -2.04440 0.125 [13,] 12 0.0204 -2.39584 0.125 [14,] 13 0.0204 -2.75016 0.125 [15,] 14 0.0204 -3.10579 0.125 [16,] 15 0.0204 -3.46202 0.125 [17,] 16 0.0204 -3.81852 0.125 [18,] 17 0.0204 -4.17514 0.125 [19,] 18 0.0204 -4.53181 0.125 [20,] 19 0.0204 -4.88851 0.125 [21,] 20 0.0204 -5.24522 0.125 > summary(TV) Oblique rotation method Oblimin Quartimin converged in 21 iterations. Loadings: Factor1 Factor2 NL1 -0.0245 -0.8055 TV2 0.0822 -0.7884 NL3 -0.0194 -0.7847 RTL4 0.6350 -0.1038 RTL5 0.7294 -0.0495 Veronica 0.8518 0.0589 SBS6 0.7504 0.0409 > > > > cleanEx(); ..nameEx <- "Random.Start" > > ### * Random.Start > > flush(stderr()); flush(stdout()) > > ### Name: Random.Start > ### Title: Generate a Random Orthogonal Rotation > ### Aliases: Random.Start > ### Keywords: multivariate > > ### ** Examples > > Global.min <- function(A,method,B=10){ + fv <- rep(0,B) + seeds <- sample(1e+7, B) + for(i in 1:B){ + cat(i," ") + set.seed(seeds[i]) + gpout <- GPFoblq(A=A, Random.Start(ncol(A)), method=method) + dtab <- dim(gpout$Table) + fv[i] <- gpout$Table[dtab[1],2] + cat(fv[i], "\n") + } + cat("Min is ",min(fv),"\n") + set.seed(seeds[order(fv)[1]]) + ans <- GPFoblq(A=A, Random.Start(ncol(A)), method=method) + ans + } > > data("Thurstone", package="GPArotation") > > Global.min(box26,"simplimax",10) 1 0.2532918 2 0.3305051 3 0.1439683 4 Warning in GPFoblq(A = A, Random.Start(ncol(A)), method = method) : convergence not obtained.1000 iterations used. 0.2531122 5 0.2473104 6 Warning in GPFoblq(A = A, Random.Start(ncol(A)), method = method) : convergence not obtained.1000 iterations used. 0.2807472 7 0.08037128 8 0.1748273 9 0.1054259 10 0.1312377 Min is 0.08037128 Oblique rotation method Simplimax converged. Loadings: [,1] [,2] [,3] [1,] -0.8313 0.6923 -0.00587 [2,] 0.5969 -0.3977 1.32555 [3,] -0.7102 -0.5263 0.07215 [4,] -0.0545 0.1623 0.91325 [5,] -1.0013 0.0741 0.00263 [6,] -0.0383 -0.6190 0.85324 [7,] -0.4236 0.4008 0.55118 [8,] 0.2429 -0.1100 1.14838 [9,] -0.9993 0.3330 -0.02234 [10,] -1.0222 -0.1509 0.03317 [11,] 0.2182 -0.5829 1.07126 [12,] -0.2693 -0.6187 0.60982 [13,] -1.2321 0.8714 -1.15555 [14,] 1.2321 -0.8714 1.15555 [15,] -0.0304 0.9837 0.03266 [16,] 0.0304 -0.9837 -0.03266 [17,] 1.2483 0.0347 1.20460 [18,] -1.2483 -0.0347 -1.20460 [19,] 0.0742 0.0748 1.00772 [20,] -1.0202 0.0358 -0.03427 [21,] -0.0401 -0.6019 0.86072 [22,] 0.0664 0.0654 0.99332 [23,] -0.9781 0.0119 -0.01506 [24,] -0.0336 -0.5700 0.86093 [25,] -0.3951 -0.1407 0.67309 [26,] -0.2818 -0.2499 0.74083 Rotating matrix: [,1] [,2] [,3] [1,] -0.371 -0.197 0.702 [2,] 1.417 -0.601 1.263 [3,] 0.176 0.898 0.305 Phi: [,1] [,2] [,3] [1,] 1.000 0.163 -0.680 [2,] 0.163 1.000 0.168 [3,] -0.680 0.168 1.000 > > > > cleanEx(); ..nameEx <- "rotations" > > ### * rotations > > flush(stderr()); flush(stdout()) > > ### Name: rotations > ### Title: Rotations > ### Aliases: oblimin quartimin targetT targetQ pstT pstQ oblimax entropy > ### quartimax Varimax simplimax bentlerT bentlerQ tandemI tandemII > ### geominT geominQ cfT cfQ infomaxT infomaxQ mccammon vgQ.oblimin > ### vgQ.quartimin vgQ.target vgQ.pst vgQ.oblimax vgQ.entropy > ### vgQ.quartimax vgQ.varimax vgQ.simplimax vgQ.bentler vgQ.tandemI > ### vgQ.tandemII vgQ.geomin vgQ.cf vgQ.infomax vgQ.mccammon > ### Keywords: multivariate > > ### ** Examples > > data(ability.cov) > factanal(factors = 2, covmat = ability.cov, rotation="oblimin") Call: factanal(factors = 2, covmat = ability.cov, rotation = "oblimin") Uniquenesses: general picture blocks maze reading vocab 0.455 0.589 0.218 0.769 0.052 0.334 Loadings: Factor1 Factor2 general 0.386 0.475 picture 0.646 blocks 0.896 maze 0.488 reading 0.990 vocab 0.791 Factor1 Factor2 SS loadings 1.756 1.688 Proportion Var 0.293 0.281 Cumulative Var 0.293 0.574 Test of the hypothesis that 2 factors are sufficient. The chi square statistic is 6.11 on 4 degrees of freedom. The p-value is 0.191 > > data("Harman", package="GPArotation") > qHarman <- GPForth(Harman8, Tmat=diag(2), method="quartimax") > qHarman2 <- quartimax(Harman8) > > data("WansbeekMeijer", package="GPArotation") > fa.unrotated <- factanal(factors = 2, covmat=NetherlandsTV, rotation="none") > > fa.varimax <- factanal(factors = 2, covmat=NetherlandsTV, + rotation="varimax", control=list(rotate=list(normalize=TRUE))) > fa.oblimin <- factanal(factors = 2, covmat=NetherlandsTV, + rotation="oblimin", control=list(rotate=list(normalize=TRUE))) > > cbind(loadings(fa.unrotated), loadings(fa.varimax), loadings(fa.oblimin)) Factor1 Factor2 Factor1 Factor2 Factor1 Factor2 NL1 0.6972803 -0.3736554 0.2360221 0.7550574 -0.02448863 0.80550694 TV2 0.7774628 -0.3184149 0.3319439 0.7717834 0.08217889 0.78835099 NL3 0.6832300 -0.3620428 0.2341260 0.7369283 -0.01944302 0.78471128 RTL4 0.6612198 0.2361132 0.6373377 0.2945535 0.63501085 0.10381118 RTL5 0.6972393 0.3026050 0.7096161 0.2723186 0.72938957 0.04951539 Veronica 0.7100285 0.4059509 0.7911239 0.2075079 0.85179157 -0.05889848 SBS6 0.6353584 0.3526947 0.7005266 0.1932262 0.75043563 -0.04089475 > > > > > ### *