mpem

mpem fits matrix-normal models and imputes incomplete matrix-variate data. One public function handles both arbitrary and structural missingness:

Installation

remotes::install_github("LHZMix/MPEM")

Arbitrary missingness

library(mpem)

set.seed(1)
X <- array(rnorm(4 * 3 * 50), dim = c(4, 3, 50))
X_arbitrary <- X
X_arbitrary[cbind(c(1, 2, 4), c(1, 3, 2), c(1, 2, 3))] <- NA

fit <- mpem(X_arbitrary, method = "arbitrary")
X_complete <- fit$imputed
fit$parameters

Structural missingness

X_structural <- X
X_structural[1:2, 2:3, 1:5] <- NA

fit_structural <- mpem(X_structural, method = "structural")
X_complete_structural <- fit_structural$imputed

The default method = "auto" uses Rect-MPEM when every incomplete observation contains one rectangular missing block and uses general MPEM otherwise.

Mixture of matrix-normal distributions

Set G > 1 in mpem() to estimate component membership and component-specific matrix-normal parameters while using weighted MPEM to handle missing values.

set.seed(7)
X_mix <- array(rnorm(4 * 3 * 200), c(4, 3, 200))
X_mix[, , 101:200] <- X_mix[, , 101:200] + 3
X_mix[1:2, 2:3, seq(1, 200, by = 4)] <- NA

mixture_fit <- mpem(X_mix, G = 2, method = "auto")
table(mixture_fit$cluster)
mixture_fit$proportions
X_mix_complete <- mixture_fit$imputed

The returned posterior responsibility matrix can be used for soft classification. Component means, row covariances, column covariances, and scales are available in mixture_fit$parameters.