Compute Factor Scores for a Single Subject in MFA
Source:R/rotation.R
compute_factor_scores_optimized.RdGiven a single subject's data X and the cluster's parameters
(mu, Lambda, Psi), this function computes the posterior factor scores
(of size T x r) in a standard Factor Analysis approach.
Details
We use the standard formula for Factor Analysis posterior means:
$$
\mathbf{Z}_i(t) = \left( \mathbf{I}_r + \Lambda^\top \Psi^{-1} \Lambda \right)^{-1}
\Lambda^\top \Psi^{-1} \left[\mathbf{x}_i(t) - \mu\right].
$$
The code is implemented in a vectorized manner. If \(r = \mathrm{ncol}(\Lambda)\),
then the output dimension is (T x r).
Examples
if (FALSE) { # \dontrun{
X_i <- list_of_data[[i]] # (T x M)
# from model$mu[[k]], model$Lambda[[k]], model$Psi[[k]]
Z_i <- compute_factor_scores_optimized(X_i, mu_k, Lambda_k, Psi_k)
dim(Z_i) # (T x r)
} # }