psych (version 1.0-17)

factor.rotate: "Hand" rotate a factor loading matrix

Description

Given a factor or components matrix, it is sometimes useful to do arbitrary rotations of particular pairs of variables. This supplements the much more powerful rotation package GRProtation and is meant for specific requirements to do unusual rotations.

Usage

factor.rotate(f, angle, col1, col2)

Arguments

f
original loading matrix
angle
angle (in degrees!) to rotate
col1
column in factor matrix defining the first variable
col2
column in factor matrix defining the second variable

Value

  • the resulting rotated matrix of loadings.

Details

Partly meant as a demonstration of how rotation works, factor.rotate is useful for those cases that require specific rotations that are not available in more advanced packages such as GPAroation.

References

http://personality-project.org/revelle/syllabi/405.syllabus.html

Examples

Run this code
## The function is currently defined as
function(f,angle,col1,col2)  {
   #hand rotate two factors from a loading matrix
   #see the GPArotation package for much more elegant procedures
     nvar<- dim(f)[2]
     rot<- matrix(rep(0,nvar*nvar),ncol=nvar)
     rot[cbind(1:nvar, 1:nvar)] <- 1
     theta<- 2*pi*angle/360
     rot[col1,col1]<-cos(theta)
     rot[col2,col2]<-cos(theta)
     rot[col1,col2]<- -sin(theta)
     rot[col2,col1]<- sin(theta)
     result <- f %*% rot
     return(result) }

Run the code above in your browser using DataCamp Workspace