Skip to contents

Given 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.

Usage

compute_factor_scores_optimized(X, mu, Lambda, Psi)

Arguments

X

A (T x M) data matrix for one subject/time-series.

mu

A length-M mean vector for the cluster.

Lambda

An (M x r) factor loading matrix for the cluster.

Psi

An (M x M) diagonal covariance matrix (unique variances).

Value

A (T x r) matrix of factor scores Z_i(t), where t = 1..T.

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)
} # }