Closed alyst closed 6 months ago
It seems like the lavaan function has some different default values for its function arguments:
Otherwise it uses the same algorithm so it should produce the same results in this case.
Matching the function arguments converges for me. For now you have to normalize the matrix manually (see #47):
Anorm, weights = kaiser_normalize(A)
rotate!(Anorm, Varimax(), atol = 1e-5, maxiter1 = 10_000, randomstarts = 10)
Arot = kaiser_denormalize(Anorm, weights)
Please note that FactorRotations.jl does not yet do some of the convenience transformations such as reflecting signs (#50) or reordering the columns (#49).
@p-gw Thank you, adjusting the method parameters helped! With the bigger matrix the method struggles more, though (but so does the lavaan implementation). I have noticed that in Varimax criterion() the Lambda-square columns are not centered, but in criterion_and_gradient() they are. Is it equivalent?
I've checked the convergence criterion: both lavaan and FactorRotations.jl use the Frobenius norm. I guess the norm would tend to be larger for larger factor matrices, so the convergence criterion gets stricter as the matrix size grows. But that probably means that user scripts that deal with variable number of factors or observed variables would have to adjust the criterion to the matrix size. Would it make sense to change it to the mean of the squared matrix elements on the method's side?
Would it make sense to change it to the mean of the squared matrix elements on the method's side?
To be honest, I don't know. The paper remains pretty vague about how the specific stopping rule was chosen. I'd probably rather keep compatability with existing packages (GPARotation, lavaan, etc.) which means the default values in FactorRotations.jl would need to be changed.
On the other hand I also had the idea of adding a relative tolerance to the stopping rule (see #7). I think this would have also caught your convergence error where the criterion just stops decreasing after a while.
I'm trying a varimax rotation of a 62x8 matrix
A_factors
with echelon pattern:and I am getting
(also tried 10^4 iterations without success, as well as other rotations, e.g. geomin)
lavaan implementation of varimax works instantly and gives reasonable results:
Here's the A_factors matrix: