File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -503,9 +503,10 @@ def _varimax(self, loadings):
503503 # and rotation matrix
504504 basis = np .dot (X , rotation_mtx )
505505
506- # transform data for singular value decomposition
507- transformed = np .dot (X .T , basis ** 3 - (1.0 / n_rows ) *
508- np .dot (basis , np .diag (np .diag (np .dot (basis .T , basis )))))
506+ # transform data for singular value decomposition using updated formula :
507+ # B <- t(x) %*% (z^3 - z %*% diag(drop(rep(1, p) %*% z^2))/p)
508+ diagonal = np .diag (np .squeeze (np .repeat (1 , n_rows ).dot (basis ** 2 )))
509+ transformed = X .T .dot (basis ** 3 - basis .dot (diagonal ) / n_rows )
509510
510511 # perform SVD on
511512 # the transformed matrix
@@ -516,7 +517,7 @@ def _varimax(self, loadings):
516517 d = np .sum (S )
517518
518519 # check convergence
519- if old_d != 0 and d / old_d < 1 + self .tol :
520+ if d < old_d * ( 1 + self .tol ) :
520521 break
521522
522523 # take inner product of loading matrix
You can’t perform that action at this time.
0 commit comments