| Title: | Sharp Precision Envelopes for Outcomes Missing at Random |
|---|---|
| Description: | Computes the range of precision that can survive when an outcome or an all-or-none block of variables is missing at random. For a stated overall observation rate and a lower bound on the observation probability, the package returns the smallest and largest efficient variance that any admissible missingness mechanism can produce, the corresponding information retention and standard error inflation, and whether a precision requirement is guaranteed, depends on the allocation of missingness, or cannot be met. It also plans minimum-cost targeted recovery of missing outcomes, and estimates the envelope from data on a partially observed continuous outcome by cross-fitted one-step estimation with a refitted bootstrap band over a prespecified grid of observation rates. The method is described in Nakamura (2026) <doi:10.3390/stats9050110>. |
| Authors: | Satoshi Nakamura [aut, cre] |
| Maintainer: | Satoshi Nakamura <[email protected]> |
| License: | BSD_3_clause + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-11-26 03:13:55 UTC |
| Source: | https://github.com/cran/precisionenvelope |
When an outcome, or an all-or-none block of variables, is missing at random
(MAR) given always observed covariates , the overall missingness rate
does not determine how much precision survives. Two mechanisms with the same
rate can leave very different efficient variances, because the loss depends
on which units go missing. This package computes the range of efficient
variance, and of information retention, that the MAR mechanisms with a given
overall observation rate and a lower bound on the
observation probability can produce. The range is sharp: both endpoints are
attained or approached by admissible mechanisms.
For a scalar target with complete-data efficient influence
function , write
and
,
and
. Under a mechanism the
observed-data efficient variance is with
, and the information
retention is . The package reports the smallest and largest
over the admissible class.
The package has three layers.
precision_envelope computes the envelope
from (or the share of the influence-function
variance explained by ) and a law for . No data
are needed. With a precision requirement it classifies each rate as
guaranteed, allocation-sensitive or inadmissible and returns the threshold
missingness rates. residual_law_gamma supplies a convenient
law for a heteroskedastic .
recovery_plan gives the minimum-cost
targeted recovery of missing outcomes that meets a requirement.
envelope_fit estimates the envelope from
data on a partially observed continuous outcome, for the mean of that
outcome, and envelope_bootstrap adds a simultaneous
refitted-bootstrap band over the grid of rates, certified phases and
confidence intervals for the threshold rates.
The package does not impute missing values, does not improve the estimate of
, and does not test MAR. It states how much precision can survive
under MAR and a stated lower bound on the observation probability.
Satoshi Nakamura [email protected]
Nakamura, S. (2026). Sharp estimand-specific precision envelopes for blockwise missing data under missing at random. Stats, 9(5), 110. doi:10.3390/stats9050110
Resamples units, refits every nuisance function and recomputes the guaranteed and possible margins at each grid rate, and forms a simultaneous band from the maximum studentized deviation. A rate is certified as guaranteed, allocation-sensitive or inadmissible only when the band excludes the other phases; otherwise it is reported as indeterminate. The band is also inverted into confidence intervals for the threshold missingness rates.
envelope_bootstrap(fit, R = 999L, alpha = 0.05, failure = c("abort", "discard"), min_success_fraction = 0.75, min_success_count = 40L) ## S3 method for class 'envelope_band' print(x, digits = 3, ...) ## S3 method for class 'envelope_band' as.data.frame(x, row.names = NULL, optional = FALSE, ...)envelope_bootstrap(fit, R = 999L, alpha = 0.05, failure = c("abort", "discard"), min_success_fraction = 0.75, min_success_count = 40L) ## S3 method for class 'envelope_band' print(x, digits = 3, ...) ## S3 method for class 'envelope_band' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
fit |
An object returned by |
R |
Number of bootstrap refits. |
alpha |
One minus the simultaneous confidence level. |
failure |
|
min_success_fraction, min_success_count
|
Thresholds used with
|
x |
An object returned by |
row.names, optional
|
Not used; present for compatibility with the generic. |
digits |
Number of decimal places to print. |
... |
Ignored. |
With successful refits, the critical value is the order statistic of
rank of the maximum absolute
studentized deviation, a conservative finite-sample choice; at least
successful refits are needed. The
guaranteed and possible margins are nonincreasing in the missingness rate,
and the band is tightened under this constraint before it is inverted into
intervals for and that respect
.
Each refit repeats the full cross-fitted estimation, so the computation time
is about R times that of envelope_fit. Call
set.seed beforehand for reproducible output.
An object of class "envelope_band", a list with components
band |
A data frame with one row per grid rate: |
critical_value, rank, alpha
|
The critical value, its rank and the level. |
attempted, successful, failure
|
Counts of refits and the failure policy. |
feasibility |
For an absolute requirement, whether it is certified to
hold with complete data; otherwise |
thresholds |
A matrix with rows |
fit |
The input fit. |
Nakamura, S. (2026). Sharp estimand-specific precision envelopes for blockwise missing data under missing at random. Stats, 9(5), 110. doi:10.3390/stats9050110
set.seed(2) n <- 400 w1 <- rnorm(n) y <- 10 + 2 * w1 + rnorm(n, sd = exp(0.3 * w1)) seen <- rbinom(n, 1, plogis(1 + 0.8 * w1)) dat <- data.frame(y = ifelse(seen == 1, y, NA), w1 = w1) fit <- envelope_fit(dat, outcome = "y", covariates = "w1", p = c(0.6, 0.8, 1.0), lower = 0.1, target = 0.8) # A small number of refits keeps the example fast; use R = 999 in practice. band <- envelope_bootstrap(fit, R = 39) band band_full <- envelope_bootstrap(fit, R = 999) as.data.frame(band_full)set.seed(2) n <- 400 w1 <- rnorm(n) y <- 10 + 2 * w1 + rnorm(n, sd = exp(0.3 * w1)) seen <- rbinom(n, 1, plogis(1 + 0.8 * w1)) dat <- data.frame(y = ifelse(seen == 1, y, NA), w1 = w1) fit <- envelope_fit(dat, outcome = "y", covariates = "w1", p = c(0.6, 0.8, 1.0), lower = 0.1, target = 0.8) # A small number of refits keeps the example fast; use R = 999 in practice. band <- envelope_bootstrap(fit, R = 39) band band_full <- envelope_bootstrap(fit, R = 999) as.data.frame(band_full)
Estimates, for the mean of a partially observed continuous outcome, the variance components, the realized information retention and the sharp precision envelope over a prespecified grid of observation rates. The nuisance functions are fitted by cross-fitting and the envelope endpoints by one-step estimators.
envelope_fit(data, outcome, covariates, observed = NULL, p, lower, target = NULL, variance_limit = NULL, folds = 2L, learners = envelope_learners(), variance_floor = NULL, propensity_clip = c(0.03, 0.995), min_observed_training = 20L) ## S3 method for class 'envelope_fit' print(x, digits = 3, ...) ## S3 method for class 'envelope_fit' plot(x, y, ...) ## S3 method for class 'envelope_fit' as.data.frame(x, row.names = NULL, optional = FALSE, ...)envelope_fit(data, outcome, covariates, observed = NULL, p, lower, target = NULL, variance_limit = NULL, folds = 2L, learners = envelope_learners(), variance_floor = NULL, propensity_clip = c(0.03, 0.995), min_observed_training = 20L) ## S3 method for class 'envelope_fit' print(x, digits = 3, ...) ## S3 method for class 'envelope_fit' plot(x, y, ...) ## S3 method for class 'envelope_fit' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
data |
A data frame with one row per unit. |
outcome |
Name of the numeric outcome column. Missing values mark
missing outcomes unless |
covariates |
Names of the completely observed numeric covariate
columns |
observed |
Optional name of a 0/1 (or logical) column marking observed outcomes. |
p |
Strictly increasing grid of overall observation rates at which
the envelope is estimated, each between |
lower |
Lower bound |
target, variance_limit
|
Optional precision requirement, as in
|
folds |
Number of cross-fitting folds, at least 2. |
learners |
A list of nuisance learners, see
|
variance_floor |
Positive lower bound applied to the fitted residual variance. The default is one thousandth of the variance of the observed outcomes. |
propensity_clip |
Lower and upper bounds applied to the fitted observation probabilities. |
min_observed_training |
Minimum number of observed outcomes required in each training fold. |
x |
An object returned by |
y, row.names, optional
|
Not used; present for compatibility with the generic. |
digits |
Number of decimal places to print. |
... |
Further arguments passed to |
The target is the outcome mean, whose complete-data influence function is
. Then and , with
and . Within each
cross-fitting fold the outcome mean is fitted on the observed outcomes of
the training folds, the residual variance is fitted to squared residuals
taken from an inner two-way split of the same observed outcomes, and the
observation probability is fitted on all training rows. The
one-step estimators of , , and the realized
use the augmented inverse-probability weighted
influence functions; the envelope endpoints at each grid rate use the
fitted favorable allocation and the fitted upper quantile of
for the adverse endpoint.
The reported Wald interval for the realized retention is marginal. For
simultaneous statements over the grid, and for phases certified at a
stated level, use envelope_bootstrap. The fitted share of
observation probabilities below lower is reported as a diagnostic; it
does not validate the lower bound or MAR.
Results depend on the random split into folds; call
set.seed beforehand for reproducible output.
An object of class "envelope_fit", a list including
mu |
The estimated outcome mean. |
A, B, C_realized, V_full, V_observed
|
Estimated variance components, complete-data efficient variance and observed-data efficient variance under the realized mechanism. |
rho_realized, rho_se, rho_ci
|
Realized information retention, its standard error and a marginal 95% Wald interval. |
table |
A data frame with one row per grid rate: |
requirement, theta
|
The requirement and the vector of margins used by
|
n, observed_count, observation_rate, share_below_lower
|
Sample description and the overlap diagnostic. |
nuisance |
The cross-fitted predictions |
The object also keeps the specification, the learners and the data needed for refitting.
Nakamura, S. (2026). Sharp estimand-specific precision envelopes for blockwise missing data under missing at random. Stats, 9(5), 110. doi:10.3390/stats9050110
envelope_bootstrap, envelope_learners,
precision_envelope
set.seed(1) n <- 500 w1 <- rnorm(n) w2 <- rbinom(n, 1, 0.4) y <- 10 + 2 * w1 + 1.5 * w2 + rnorm(n, sd = exp(0.3 * w1)) seen <- rbinom(n, 1, plogis(1 + 0.8 * w1)) dat <- data.frame(y = ifelse(seen == 1, y, NA), w1 = w1, w2 = w2) fit <- envelope_fit(dat, outcome = "y", covariates = c("w1", "w2"), p = c(0.6, 0.7, 0.8, 0.9), lower = 0.1, target = 0.8) fit plot(fit)set.seed(1) n <- 500 w1 <- rnorm(n) w2 <- rbinom(n, 1, 0.4) y <- 10 + 2 * w1 + 1.5 * w2 + rnorm(n, sd = exp(0.3 * w1)) seen <- rbinom(n, 1, plogis(1 + 0.8 * w1)) dat <- data.frame(y = ifelse(seen == 1, y, NA), w1 = w1, w2 = w2) fit <- envelope_fit(dat, outcome = "y", covariates = c("w1", "w2"), p = c(0.6, 0.7, 0.8, 0.9), lower = 0.1, target = 0.8) fit plot(fit)
envelope_learners collects the three learners used by
envelope_fit: one for the outcome mean, one for the residual
variance and one for the observation probability. learner_linear
and learner_logistic construct the default least-squares and
logistic regression learners.
envelope_learners(mean = learner_linear(), variance = learner_linear(), propensity = learner_logistic()) learner_linear() learner_logistic()envelope_learners(mean = learner_linear(), variance = learner_linear(), propensity = learner_logistic()) learner_linear() learner_logistic()
mean |
Learner for the outcome mean |
variance |
Learner for the residual variance, fitted to squared residuals. |
propensity |
Learner for the observation probability, fitted to the 0/1 observation indicator. It must return probabilities. |
A learner is a function function(x, y, newx) that fits a model to
the numeric covariate matrix x and response y and returns a
numeric vector of predictions for the rows of the matrix newx. Any
regression method can be wrapped in this form, for example a spline or a
random forest from another package. The defaults standardize the
covariates and fit, with an intercept, ordinary least squares
(learner_linear) or logistic regression (learner_logistic).
Fitted residual variances are bounded below and fitted probabilities are
clipped by envelope_fit.
envelope_learners returns a named list of three functions;
learner_linear and learner_logistic return a learner.
# A learner that adds squared terms of every covariate. quadratic <- function(x, y, newx) { learner_linear()(cbind(x, x^2), y, cbind(newx, newx^2)) } learners <- envelope_learners(mean = quadratic, variance = quadratic) names(learners)# A learner that adds squared terms of every covariate. quadratic <- function(x, y, newx) { learner_linear()(cbind(x, x^2), y, cbind(newx, newx^2)) } learners <- envelope_learners(mean = quadratic, variance = quadratic) names(learners)
Computes, for each overall observation rate , the smallest and largest
efficient variance that a missing-at-random mechanism with observation
probability bounded below by lower can produce, together with the
value under missing completely at random (MCAR). With a precision
requirement it classifies each rate and returns the threshold missingness
rates. No data are needed: the inputs describe the target and the
covariates at the planning stage.
precision_envelope(p, lower, A = NULL, r2 = NULL, b = 1, weights = NULL, covariate = c("continuous", "strata"), target = NULL, variance_limit = NULL) ## S3 method for class 'precision_envelope' print(x, digits = 3, ...) ## S3 method for class 'precision_envelope' plot(x, y, n = 201L, ...) ## S3 method for class 'precision_envelope' as.data.frame(x, row.names = NULL, optional = FALSE, ...)precision_envelope(p, lower, A = NULL, r2 = NULL, b = 1, weights = NULL, covariate = c("continuous", "strata"), target = NULL, variance_limit = NULL) ## S3 method for class 'precision_envelope' print(x, digits = 3, ...) ## S3 method for class 'precision_envelope' plot(x, y, n = 201L, ...) ## S3 method for class 'precision_envelope' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
p |
Numeric vector of overall observation rates, each between
|
lower |
Lower bound |
A |
The between-covariate variance component
|
r2 |
The share |
b |
Values of the residual variance |
weights |
Optional non-negative masses for the values in |
covariate |
|
target |
Optional retention requirement |
variance_limit |
Optional absolute requirement: the observed-data
efficient variance must not exceed this value. Supply at most one of
|
x |
An object returned by |
y |
Not used; present for compatibility with the generic. |
row.names, optional
|
Not used; present for compatibility with the generic. |
digits |
Number of decimal places to print. |
n |
Number of missingness rates at which the curves are drawn. |
... |
Further arguments passed to |
Write . Over observation laws with
and , the favorable
endpoint minimizes and is
attained by the clipped square-root rule
. On a
covariate space without atoms the adverse endpoint is
where is the quantile function of . The MCAR
value is , which always lies between the endpoints.
Information retention is ,
and the standard error is inflated by the factor . The
MCAR-equivalent missingness rate of a value is
, the MCAR rate that would give the same retention.
A requirement translates into a residual budget , equal to
for a retention requirement
and to variance_limit for an absolute one. A rate is
guaranteed when , so that every admissible mechanism
meets the requirement; allocation-sensitive when only
, so that some mechanisms meet it and others do not;
and inadmissible when . The thresholds ,
and are the missingness rates at which the
adverse, MCAR and favorable margins reach zero. An absolute requirement that
fails even with complete data is reported as infeasible. A requirement on
the half-width of a 95% interval from units corresponds to
variance_limit = n * (h / qnorm(0.975))^2.
An object of class "precision_envelope", a list with components
table |
A data frame with one row per rate: |
A, B, V_full
|
The variance components and the complete-data
efficient variance |
lower, q_max
|
The lower bound and the largest admissible missingness rate. |
requirement |
|
thresholds |
|
covariate, b, weights
|
The inputs that describe the law of
|
The plot method draws the three retention curves against the
missingness rate and returns their values invisibly.
Nakamura, S. (2026). Sharp estimand-specific precision envelopes for blockwise missing data under missing at random. Stats, 9(5), 110. doi:10.3390/stats9050110
residual_law_gamma, recovery_plan,
envelope_fit
# Planning with a constant residual variance: 25% of outcomes expected to be # missing, covariates explaining 30% of the outcome variance, and an # observation probability of at least 0.10 for every covariate profile. env <- precision_envelope(p = c(0.95, 0.85, 0.75, 0.65), lower = 0.10, r2 = 0.30, target = 0.80) env # The analytic illustration of Nakamura (2026, Section 5.1): residual # variance 0.1 or 1.9 with equal probability, A = 1 and lower bound 0.2. ill <- precision_envelope(p = c(0.9, 0.75, 0.6), lower = 0.2, A = 1, b = c(0.1, 1.9), target = 0.80) ill$thresholds plot(ill) # A heteroskedastic law with coefficient of variation 0.8. het <- precision_envelope(p = 0.75, lower = 0.10, r2 = 0.30, b = residual_law_gamma(cv = 0.8)) as.data.frame(het)[, c("q", "rho_favorable", "rho_mcar", "rho_adverse")]# Planning with a constant residual variance: 25% of outcomes expected to be # missing, covariates explaining 30% of the outcome variance, and an # observation probability of at least 0.10 for every covariate profile. env <- precision_envelope(p = c(0.95, 0.85, 0.75, 0.65), lower = 0.10, r2 = 0.30, target = 0.80) env # The analytic illustration of Nakamura (2026, Section 5.1): residual # variance 0.1 or 1.9 with equal probability, A = 1 and lower bound 0.2. ill <- precision_envelope(p = c(0.9, 0.75, 0.6), lower = 0.2, A = 1, b = c(0.1, 1.9), target = 0.80) ill$thresholds plot(ill) # A heteroskedastic law with coefficient of variation 0.8. het <- precision_envelope(p = 0.75, lower = 0.10, r2 = 0.30, b = residual_law_gamma(cv = 0.8)) as.data.frame(het)[, c("q", "rho_favorable", "rho_mcar", "rho_adverse")]
Finds the least costly increase of the observation probabilities, from a
current observation law, that brings the residual component
down to a required value. The solution is the
cost-adjusted square-root rule
,
where is the current observation probability and the cost
of raising it by one unit.
recovery_plan(b, baseline, A = NULL, target = NULL, variance_limit = NULL, residual_target = NULL, cost = 1, weights = NULL) ## S3 method for class 'recovery_plan' print(x, digits = 3, ...)recovery_plan(b, baseline, A = NULL, target = NULL, variance_limit = NULL, residual_target = NULL, cost = 1, weights = NULL) ## S3 method for class 'recovery_plan' print(x, digits = 3, ...)
b |
Residual variances |
baseline |
Current observation probabilities |
A |
Between-covariate variance component, needed with |
target |
Retention requirement in |
variance_limit |
Absolute limit on the observed-data efficient variance. |
residual_target |
Required value of the residual component itself.
Supply exactly one of |
cost |
Positive marginal cost of raising the observation probability
by one unit, a single value or one value per entry of |
weights |
Optional masses of the entries of |
x |
An object returned by |
digits |
Number of decimal places to print. |
... |
Ignored. |
For a unit that is currently missing, the planned recovery probability is
. The plan treats ,
and the costs as known; with estimated inputs it is a plug-in
planning calculation and carries no inferential guarantee for an adaptive
recovery design.
An object of class "recovery_plan", a list with components
status |
|
units |
A data frame with |
baseline_rate, final_rate, added_rate, added_cost
|
Mean observation probabilities before and after recovery, their difference and the expected added cost per unit. |
C_complete, C_baseline, C_target, C_achieved
|
The residual component with complete data, at baseline, as required and as achieved. |
eta |
The multiplier of the square-root rule. |
Nakamura, S. (2026). Sharp estimand-specific precision envelopes for blockwise missing data under missing at random. Stats, 9(5), 110. doi:10.3390/stats9050110
# Two equally sized strata; the high-variance stratum is observed half the # time. Recover enough of it to reach 80% retention. plan <- recovery_plan(b = c(0.1, 1.9), baseline = c(1, 0.5), A = 1, target = 0.80) plan plan$units# Two equally sized strata; the high-variance stratum is observed half the # time. Recover enough of it to reach 80% retention. plan <- recovery_plan(b = c(0.1, 1.9), baseline = c(1, 0.5), A = 1, target = 0.80) plan plan$units
Returns equally weighted quantiles of a gamma distribution with a given
mean and coefficient of variation, for use as the argument b of
precision_envelope when the residual variance
is expected to vary across covariate profiles.
residual_law_gamma(cv, n = 1000L, mean = 1)residual_law_gamma(cv, n = 1000L, mean = 1)
cv |
Coefficient of variation of |
n |
Number of quantiles. |
mean |
Mean of the returned values. |
The values are the gamma quantiles at , ,
rescaled to have exactly the requested mean. The gamma family is a
convenient planning assumption, not a model the method requires; any vector
of plausible residual variances, for example fitted values from a pilot
study, can be passed to precision_envelope instead.
A numeric vector of length n.
b <- residual_law_gamma(cv = 0.5) c(mean = mean(b), cv = sd(b) / mean(b))b <- residual_law_gamma(cv = 0.5) c(mean = mean(b), cv = sd(b) / mean(b))