inject_uncertainty: Inject imputation uncertainty into predictions

View source: R/helper_vimpute.R

inject_uncertaintyR Documentation

Inject imputation uncertainty into predictions

Description

Adds stochastic noise to point predictions to properly reflect imputation uncertainty. Called after model prediction, before value assignment.

Usage

inject_uncertainty(
  preds,
  method = "none",
  scale = NULL,
  residuals = NULL,
  y_obs = NULL,
  score_obs = NULL,
  score_miss = NULL,
  pmm_k = 5L,
  pmm_k_method = "random",
  X_obs = NULL,
  X_miss = NULL
)

Arguments

preds

Numeric vector of predicted values for missing observations

method

One of "none", "normalerror", "resid", "pmm", "midastouch"

scale

Scale estimate (sigma hat) from model. Required for "normalerror".

residuals

Training residuals. Required for "resid".

y_obs

Observed values of target variable. Required for "pmm", "midastouch".

score_obs

Model scores for observed rows. Required for "pmm".

score_miss

Model scores for missing rows. Required for "pmm".

pmm_k

Number of donors for pmm/midastouch (default 5).

pmm_k_method

Aggregation for pmm when k > 1 (default "random").

X_obs

Predictor matrix for observed rows. Required for "midastouch".

X_miss

Predictor matrix for missing rows. Required for "midastouch".

Value

Numeric vector of adjusted predictions (same length as preds)


VIM documentation built on Sept. 2, 2026, 5:07 p.m.