\encoding{UTF-8}
\name{NormalizingWeight}
\alias{NormalizingWeight}
\title{Normalizing Weights for Factor Rotation}
\usage{
    NormalizingWeight(A, normalize=FALSE)
}
\arguments{
    \item{A}{A factor loading matrix.}
    \item{normalize}{Indicates if and how the matrix should be normalized.
         If \code{FALSE} (default), no normalization is done.
         If \code{TRUE}, Kaiser normalization is applied.
         If a numeric vector of length \code{nrow(A)}, columns are divided
         by these weights before rotation and multiplied after.
         If a function, it should take \code{A} as its argument and return
         a numeric vector used as weights.}
}
\value{
  A numeric vector of normalizing weights. This function is not exported
  from the NAMESPACE and is only called internally by the gradient projection
  rotation functions. See \code{\link{GPFRSorth}} for details on the
  \code{normalize} argument.
}
\description{
  Internal utility function that computes normalizing weights for factor
  loading matrices prior to rotation. Called by \code{GPForth},
  \code{GPFoblq}, and the random-start wrappers.
}
\details{
  \code{NormalizingWeight} is not exported from the NAMESPACE and is
  called internally by \code{GPForth}, \code{GPFoblq}, and the
  random-start wrapper functions. For a full description of the
  \code{normalize} argument and its options, see \code{\link{GPFRSorth}}.

  The choice of normalization method can affect the rotation solution
  and its interpretation. For a detailed investigation of the effects
  of normalization on factor rotations, see Nguyen and Waller (2023).
}
\examples{
  data("CCAI", package = "GPArotation")
  # Kaiser normalization
  factanal(factors = 3, covmat = CCAI_R, n.obs = 461, rotation = "oblimin",
           control = list(rotate = list(normalize = TRUE)))
           
  # Cureton-Mulaik normalization passed as a function.
  # May result in convergence problems.
  NormalizingWeightCM <- function(L) {
    Dk    <- diag(sqrt(diag(L \%*\% t(L)))^-1) \%*\% L
    wghts <- rep(0, nrow(L))
    fpls  <- Dk[, 1]
    acosi <- acos(ncol(L)^(-1/2))
    for (i in 1:nrow(L)) {
      num      <- acosi - acos(abs(fpls[i]))
      dem      <- acosi - (function(a, m)
                    ifelse(abs(a) < (m^(-1/2)), pi/2, 0))(fpls[i], ncol(L))
      wghts[i] <- cos(num / dem * pi/2)^2 + 0.001
    }
    wghts * sqrt(diag(L \%*\% t(L)))^-1
  }

  data(Harman, package = "GPArotation")
  quartimin(Harman8, normalize = NormalizingWeightCM(Harman8), randomStarts = 100)
  quartimin(Harman8, normalize = TRUE, randomStarts = 100)
}
\references{
  Nguyen, H.V. and Waller, N.G. (2023). Local minima and factor rotations
    in exploratory factor analysis. \emph{Psychological Methods},
    \bold{28}(5), 1122--1141.
    doi: 10.1037/met0000467
}
\seealso{
  \code{\link{GPFRSorth}},
  \code{\link{GPForth}}
}
\keyword{internal}