Hi All, I'd like to build a package for the community that replicates the output produced by SAS "proc varclus". According to the SAS documentation, the first few steps are: 1. Find the first two principal components. 2. Perform an orthoblique rotation (quartimax rotation) on eigenvectors. 3. Assign each variable to the rotated component with which it has the higher squared correlation. The cartoon example below attempt to do this, but I found my results differ from SAS in "pc3" (i.e, the standardize component scores). I'd appreciate your help in whether you see anything wrong in "pc2" or "pc3"? set.seed(1) x1=rnorm(200); x2=0.9*x1; x3=0.7*x1; x4=x1*x1; x5=x1*x1*x1; x6=rnorm(200); x7=0.9*x6; x8=0.7*x6; x9=x6*x6; x10=x6*x6*x6; x <- cbind(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) require(GPArotation) pc1 <- princomp(x, cor = TRUE, scores = TRUE) pc2 <- quartimax(pc1$loadings[,1:2],normalize=TRUE)$loadings pc3 <- scale(x%*% pc2) pc4 <- apply(x, 2, function(x) cor(x, pc3)^2) Thanks in advance for any help! Axel. [[alternative HTML version deleted]]
Frank Harrell
2011-Apr-10 16:52 UTC
[R] Orthoblique rotation on eigenvectors (SAS VARCLUS)
See the varclus function in the Hmisc package. Frank Axel Urbiz wrote:> > Hi All, > > I'd like to build a package for the community that replicates the output > produced by SAS "proc varclus". According to the SAS documentation, the > first few steps are: > > 1. Find the first two principal components. > 2. Perform an orthoblique rotation (quartimax rotation) on eigenvectors. > 3. Assign each variable to the rotated component with which it has the > higher > squared correlation. > The cartoon example below attempt to do this, but I found my results > differ > from SAS in "pc3" (i.e, the standardize component scores). > > I'd appreciate your help in whether you see anything wrong in "pc2" or > "pc3"? > > set.seed(1) > x1=rnorm(200); x2=0.9*x1; x3=0.7*x1; x4=x1*x1; x5=x1*x1*x1; > x6=rnorm(200); x7=0.9*x6; x8=0.7*x6; x9=x6*x6; x10=x6*x6*x6; > x <- cbind(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) > > require(GPArotation) > pc1 <- princomp(x, cor = TRUE, scores = TRUE) > pc2 <- quartimax(pc1$loadings[,1:2],normalize=TRUE)$loadings > pc3 <- scale(x%*% pc2) > pc4 <- apply(x, 2, function(x) cor(x, pc3)^2) > > Thanks in advance for any help! > > Axel. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >----- Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Orthoblique-rotation-on-eigenvectors-SAS-VARCLUS-tp3438695p3440064.html Sent from the R help mailing list archive at Nabble.com.
I really like your varclus function Frank. I have a question about the quartimax rotation of the 1st two eigen vectors as the SAS VARCLUS algorithm dictates. According to the SAS user guide example of VARCLUS the only thing needed to perform the cluster analysis is the variable correlation matrix. Is that the case? The following is the SAS user guide example website. http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_varclus_sect020.htm Larry -- View this message in context: http://r.789695.n4.nabble.com/Orthoblique-rotation-on-eigenvectors-SAS-VARCLUS-tp3438695p4187270.html Sent from the R help mailing list archive at Nabble.com.