-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add orthomax factor rotations #130
base: master
Are you sure you want to change the base?
Conversation
Addresses issue #67 |
4 space indentation, please. |
It seems the method I found in the article by Stegman et al. (2006) only works for small For larger |
I think The low-level functions should be named after the particular rotation method, and accept the factor matrix as a parameter with any additional parameters, default or kw arguments, e.g. varimax(F, γ = 1.0, maxiter = 10, tol = 1e-6) The high-level interface has to operate on stat. model objects with additional parameters for rotation method specification. Rotation algorithm can be encoded as a type, so it would be easy to specialize a particular implementation. M = fit(PCA, X)
rotate!(M, Orthmax)
rotate!(M, Varimax; γ = 1.0, maxiter = 10, tol = 1e-6) The high-level rotation function retrieves model's factor matrix, |
Thanks for the feedback! Will continue to work on this when time allows. |
Here is finally a new version. I replaced the old algorithm with the method that is used in the GPArotation package for R, since it is easy this way to implement all kinds of factor rotations. Especially, it is possible to provide oblique as well as orthogonal rotations. I still need to write more tests and documentation, but I wanted to double check on the interface first. The numerical crunch is done by the two versions of the One concern could be that introducing more criteria will lead to more types. Not sure if that is a concern though. In terms of user interface, I am offering one general Is this interface in line with the general package philosophy? I've seen that symbols are used in other places to select methods, which could of course be a possibility here too, but it would lead to long switch statements that need to be modified each time a new rotation criterion gets added. |
Just to clarify, the interface would be M = fit(FactorAnalysis, X)
rotate!(M, CrawfordFerguson{Orthogonal}(κ = 0.0)) or rotate!(M, Oblimin{Oblique}(ɣ = 0.0)) when applied to existing models (currently PCA and FA). If one simply has a matrix of loadings Lrot = rotate(L, Oblimin{Oblique}(ɣ = 0.0)) There could be convenience types like |
The |
Thank you for the feedback! I addressed what you pointed out and made the appropriate changes. I will add the missing documentation, some more factor rotation types, and appropriate testing code soon. |
What is the status on getting this feature released? I am very interested and would be happy to help if there is anything missing still. |
I haven't managed to work on this in a long time since my projects moved in another direction. The code to perform factor rotations is basically finished and ready to use. It should be reasonably well documented in The major road block to getting the PR out is testing and writing more documentation. Also it's been 1.5 years since I last touched it, so I guess it will have to be synchronized with an updated version of the package. Compared to something like the R package GPArotation it also supports quite few rotations currently. But I think that is more of a "would be nice to have" thing than a "must have" thing. |
Looking at the code now, there might be enough tests to get this off the ground. What do you think, @wildart? I think the one thing missing is to update the Sphinx documentation. [EDIT] Oh I see there is a Documenter.jl documentation now also. Is it enough to update that one or is the Sphinx documentation still in use as well? |
Thanks for the heads-up. I ended up writing my own implementation in a separate package. I think it has somewhat more functionality than proposed here, such as 'gradient-free' methods via automatic differentiation. If you are interested you can take a look: https://github.com/p-gw/FactorRotations.jl |
This is a start to add factor rotations to MultivariateStats.jl. The implemented algorithm is currently what is described in the review paper
with the addition of choosing a random rotation matrix if the identity matrix is not a good starting point (this is what Matlab does in
rotatefactors
and was suggested by @haotian127).Currently there are two suggestions for interfaces: Either the standard
fit
interface orrotatefactors
which is more similar to Matlabs interface. I am not a big fan of thefit
interface since, contrary to the scikit-learn original where it presumably came from, is not really chainable since keyword parameters differ from onefit
function to the other. However, if this is the preferred way of adding things to MultivariateStats.jl then I will not stand in the way.I like the idea of having a different type for each rotation algorithm. This is what JuliaLang started to do with e.g. the Algorithm for SVD in the
LinearAlgebra
package as well. This way multiple dispatch can be used (as I currently have it in therotatefactors
interface) instead of a chain ofisa()
checks or checking a symbol switch such as:orthomax
.Many things are still missing
fit
vsrotatefactors
FactorRotation
objectFactorAnalysis
object desirable?Addresses #67