View source: R/missing_data_em.R
| check_na | R Documentation |
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:
Every feature observed. Contributes the ordinary complete-data term to the likelihood.
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.
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.
check_na(Z, lucid_model = c("early", "parallel"))
Z |
For |
lucid_model |
Either |
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.
analyze_missing_pattern for the per-layer detail.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.