ZI‑PLN-PCA with missing data using log(S) parametrization
Source:R/Miss_ZIPLNPCA_logS.R
Miss.ZIPLNPCA.logS.RdFits a zero‑inflated Poisson log‑normal (ZI‑PLN-PCA) latent factor model to a
count matrix with missing values, using a variational objective and an
alternative parametrization on the variational scales:
$$ \code{log(S)} \text{ instead of } S. $$
This guarantees positivity of \(S\) and allows simple box constraints on
\(log(S) \) via tolLogS.
Arguments
- Y
Numeric
n x pcount matrix. May containNA.- X
Numeric design matrix with
n*prows anddcolumns, aligned withvec(Y)(vectorization by columns).- q
Integer, latent rank (dimension of the latent space).
- params
Optional list of initial parameters. If
NULL, they are initialized byInit_ZIP. If provided, it must include a positiveS; the function internally addslogS <- log(S).- config
Optional list of optimizer controls. If
NULL, defaults toPLNPCA_param()$config_optim.- tolxi
Numeric tolerance for the Jaakkola‑type \(\xi\) updates in the logistic bound (default
1e-4).- tolLogS
Numeric upper bound applied to
logS(box constraint). Defaults toInf. Use this to avoid excessively large variational scales when needed.
Value
A list with components:
mStepModel parameters:
gamma(d x 1),beta(d x 1), and loadingsC(p x q).eStepVariational parameters: means
M(n x q), scalesS(n x q), and logistic bound parametersxi(n x p).predList with predictors and expected counts:
mu(n x p),nu(n x p), backend Poisson meanA(n x p), andpredictedrecomputed in R: $$\exp\!\big( X B + M C^\top + 0.5\,(S\odot S)\,(C\odot C)^\top \big).$$imputedn x pmatrix equal toxi * Aat missing entries ofY, andYelsewhere.iterNumber of iterations;
elboPath(trajectory of ELBO);elbo(final ELBO).params.initInitial parameters passed to the backend (with
logSadded).monitoringOptimizer diagnostics/logs.
gradB, gradD, gradC, gradM, gradSELBO gradients w.r.t. corresponding parameters (via
Elbo_grad).
Details
Missing entries are handled by a mask R = 1_{observed}(Y); a working
matrix Y.na sets missings to 0 for the objective evaluation.
Box constraints are set on logS via config$upper_bounds, using
tolLogS. Make sure X matches vec(Y).
See also
Miss.ZIPLNPCA for the S parametrization,
Init_ZIP, Elbo_grad