Compute Factor (PC) Scores for a Single Subject in a Mixture PCA Cluster
Source:R/rotation.R
compute_factor_scores_mpca_single.RdGiven a single subject's data X, and the cluster parameters (mu, W, sigma2), this function computes the posterior factor scores (T x r) under a PPCA assumption with isotropic noise sigma^2 * I.
Details
We use the posterior mean formula for PPCA with isotropic noise: z(t) = inv(W^T W + sigma2 * I_r) * W^T * (x(t) - mu). This is applied row by row in X, but we can do it in a vectorized manner.
If your noise model is not purely sigma2 * I, you will need a more general approach. Also note that if T=1, the result might be a (1 x r) matrix or (r)-vector, so be sure to keep it as a matrix if desired.