I'm trying to add a function to manually (or by-hand, or judgmentally) rotate a factor loadings matrix from principal components analysis to the qmethod
R package.
By-hand rotation as in: one specifies the angle by which to rotate any given pair of factors.
(Yeah it's weird, but it makes sense in Q Methodology.)
For now, I'm not looking for an interactive GUI (though that'd be real nice), but just a CLI interface where you press left
or right
and get updated plots and finally say OK
.
The baseline is something like this from the legacy PQMethod program.
Here's a short video.
My current approach is to use psych::factor.rotate()
, and to program a somewhat interactive (as in right
, left
, OK
) CLI interface on top of that with updating plots.
Still, I wonder whether someone hasn't done this already.
I googled away, but came up short (couldn't even find a by-hand rotation procedure other than psych::factor.rotate()
.
Any suggestions?
Ps.: bonus if you have a suggestion for how to do this with an interactive GUI.
Pps.: anyone kind enough to add a qmethod
tag to this? I don't have the necessary points.
I'd give manipulate
a try - something in the veins of:
library(psych)
library(manipulate)
l <- l_orig <- unclass(loadings(principal(Harman.5, 2, scores=TRUE)))
manipulate(
{
if(rotateRight)
l <<- factor.rotate(l, angle, 1, 2)
if (rotateLeft)
l <<- factor.rotate(l, -1*angle, 1, 2)
plot(l, xlim = c(-1, 1), ylim = c(-1, 1), xlab = 1, ylab = 2); abline(v = 0); abline(h = 0)
},
angle = slider(1, 90, step=1, initial = 1, label = "Angle"),
rotateRight = button(">"),
rotateLeft = button("<")
)
l; l_orig