Skip to contents

Given a single cluster's parameters (mu, Lambda, Psi) and data X, this function returns the estimated factor scores.

Usage

compute_factor_scores(X, mu, Lambda, Psi)

Arguments

X

A numeric matrix of size (T x M).

mu

A length-M mean vector.

Lambda

An M x r loading matrix.

Psi

An M x M diagonal matrix for unique variances.

Value

A (T x r) matrix of factor scores.

Details

This follows the standard posterior mean formula in factor analysis: \(\mathrm{E}[Z|X] = (I + \Lambda^T \Psi^{-1} \Lambda)^{-1} \Lambda^T \Psi^{-1} (X - \mu)\).

Examples

if (FALSE) { # \dontrun{
# Suppose we have X (T x M), mu (M), Lambda (M x r), Psi (M x M).
scores <- compute_factor_scores(X, mu, Lambda, Psi)
head(scores)
} # }