check_na: Classify each subject's omics missingness pattern

View source: R/missing_data_em.R

check_naR Documentation

Classify each subject's omics missingness pattern

Description

Assigns every subject to one of the three missingness categories the LUCID EM algorithm branches on, and reports whether imputation is required at all. The categories follow the incomplete-omics extension of LUCID:

complete (code 1)

Every feature observed. Contributes the ordinary complete-data term to the likelihood.

sporadic (code 2)

Some but not all features observed. These are the subjects that require imputation: the missing coordinates are integrated out against the fitted cluster model in the I-step.

listwise (code 3)

No feature observed for this layer. The omics term drops out of that subject's likelihood entirely, so the subject still informs the exposure and outcome models but needs no imputation.

The distinction matters for cost as well as correctness: impute_flag is TRUE only when at least one sporadic subject exists, and a dataset whose missingness is purely listwise is fitted without any imputation step.

A warning is issued for any feature more than half missing, per layer.

Usage

check_na(Z, lucid_model = c("early", "parallel"))

Arguments

Z

For lucid_model = "early", an N by M omics matrix. For "parallel", a list of such matrices, one per layer, all with the same number of rows; anything else is an error.

lucid_model

Either "early" or "parallel". A serial fit calls this once per stage rather than passing "serial" here.

Value

For "early", a list with index (an N by M logical matrix that is TRUE where observed), indicator_na (the length-N vector of codes 1, 2, 3 above), impute_flag (a single logical), and missing_analysis (the analyze_missing_pattern result).

For "parallel", index, indicator_na and layer_analyses are lists with one element per layer, impute_flag is a logical vector over layers, and cross_layer_summary adds n_layers, n_observations, features_per_layer, missing_pattern_counts (a table of the joint across-layer pattern, so that subjects missing an entire layer can be distinguished from those missing scattered features in several) and total_missing_prop, the proportion of missing cells pooled over layers rather than the mean of per-layer rates, which would weight a one-feature layer as heavily as a fifty-feature one.

See Also

analyze_missing_pattern for the per-layer detail.

Examples

Z <- matrix(rnorm(200), nrow = 20)
Z[1:2, 1] <- NA   # sporadic
Z[20, ] <- NA     # listwise
table(check_na(Z, lucid_model = "early")$indicator_na)

LUCIDus documentation built on Sept. 3, 2026, 1:06 a.m.