Learn R Programming

⚠️There's a newer version (0.1.2) of this package.Take me there.

NMAR

NMAR provides estimators for finite-population means when outcomes are subject to nonignorable nonresponse (Not Missing at Random, NMAR). It supports iid data.frame inputs and complex survey designs via survey::survey.design, and exposes a unified interface through nmar().

Methods

NMAR currently provides the following engines:

  • el_engine(): empirical likelihood (Qin, Leung and Shao, 2002).
  • exptilt_engine(): exponential tilting (Riddles, Kim and Im, 2016).
  • exptilt_nonparam_engine(): nonparametric exponential tilting for aggregated categorical data (Riddles, Kim and Im, 2016, Appendix 2).

References:

  • Qin, J., Leung, D., and Shao, J. (2002). Estimation with survey data under nonignorable nonresponse or informative sampling. Journal of the American Statistical Association, 97(457), 193-200. https://doi.org/10.1198/016214502753479338
  • Riddles, M. K., Kim, J. K., and Im, J. (2016). A propensity-score-adjustment method for nonignorable nonresponse. Journal of Survey Statistics and Methodology, 4(2), 215-245. https://doi.org/10.1093/jssam/smv047

See browseVignettes("NMAR") and the package website for worked examples and engine-specific assumptions: https://ncn-foreigners.ue.poznan.pl/NMAR/.

Installation

Install the development version from GitHub:

# install.packages("pak")
pak::pak("ncn-foreigners/NMAR")

Or with remotes:

# install.packages("remotes")
remotes::install_github("ncn-foreigners/NMAR")

To build vignettes locally:

remotes::install_github("ncn-foreigners/NMAR", build_vignettes = TRUE)

Usage

Formula interface

nmar() uses a two-sided formula with the outcome on the left-hand side. In the common “missing values indicate nonresponse” workflow, nonrespondents are encoded as NA in the outcome.

Many engines support a partitioned right-hand side via | (e.g., y_miss ~ block1_vars | block2_vars), but the interpretation of these blocks is engine-specific. See ?el_engine and ?exptilt_engine for details.

Example

suppressPackageStartupMessages(library(NMAR))

data("riddles_case1", package = "NMAR")

# Empirical likelihood (EL)
fit_el <- nmar(
  y ~ x,
  data = riddles_case1,
  engine = el_engine(variance_method = "none")
)
summary(fit_el)
#> NMAR Model Summary
#> =================
#> y mean: -1.001986
#> Converged: TRUE 
#> Variance method: none 
#> Variance notes: Variance skipped (variance_method='none') 
#> Total units: 500 
#> Respondents: 368 
#> Call: nmar(y ~ x, data = <data.frame: N=500>, engine = empirical_likelihood)
#> 
#> Missingness-model coefficients:
#>              Estimate
#> (Intercept)  0.860555
#> y           -0.175376

# Exponential tilting (ET)
fit_et <- nmar(
  y ~ x,
  data = riddles_case1,
  engine = exptilt_engine(y_dens = "normal", family = "logit", variance_method = "none")
)
summary(fit_et)
#> NMAR Model Summary (Exponential tilting)
#> =================================
#> y mean: -1.003974
#> Converged: TRUE 
#> Variance method: none 
#> Call: nmar(y ~ x, data = <data.frame: N=?>, engine = exponential_tilting)
#> 
#> Response-model (theta) coefficients:
#>   (Intercept)          : 0.864080
#>   y                    : -0.170216

Result objects returned by nmar() support methods such as summary(), weights(), se(), and confint(), and broom-style tidy() / glance() via the generics package.

Survey designs

if (requireNamespace("survey", quietly = TRUE)) {
  suppressPackageStartupMessages(library(survey))
  set.seed(1)
  d <- riddles_case1
  d$w <- runif(nrow(d), 0.5, 2)
  des <- survey::svydesign(ids = ~1, weights = ~w, data = d)

  fit_svy <- nmar(y ~ x, data = des, engine = el_engine(variance_method = "none"))
  summary(fit_svy)
}
#> NMAR Model Summary
#> =================
#> y mean: -1.005961
#> Converged: TRUE 
#> Variance method: none 
#> Variance notes: Variance skipped (variance_method='none') 
#> Total units: 621.7412 
#> Respondents: 368 
#> Call: nmar(y ~ x, data = <survey.design: N=621.741>, engine = empirical_likelihood)
#> 
#> Missingness-model coefficients:
#>              Estimate
#> (Intercept)  0.893453
#> y           -0.129256

Getting help

If you encounter a clear bug, please file an issue with a minimal reproducible example on GitHub

Citation

If you use NMAR in academic work, please cite the package and the relevant method paper(s):

citation("NMAR")

Authors and acknowledgments

Research grant: OPUS 20 #2020/39/B/HS4/00941

Copy Link

Version

Install

install.packages('NMAR')

Version

0.1.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Maciej Ber<c4><99>sewicz

Last Published

January 16th, 2026

Functions in NMAR (0.1.1)

el_build_equation_system_survey

Empirical likelihood equations for survey designs (design-weighted QLS system)
el_build_equation_system

Empirical likelihood estimating equations
el_build_result

Build EL result object (success or failure)
el_core_helpers

EL core helpers
el_assert_no_offset

Assert that terms object lacks offsets
el

Empirical likelihood estimator
el_build_start

Build starting values for the EL solver (beta, z, lambda)
create_verboser

Create Verbose Printer Factory
el_augment_strata_aux

Strata augmentation for survey designs
el_denominator

Build denominator and floor pack
el_engine

Empirical likelihood (EL) engine for NMAR
el_check_auxiliary_inconsistency_matrix

Check auxiliary means consistency against respondents' sample support.
el_compute_diagnostics

Compute diagnostics at the EL solution
el_log_solver_result

Log solver termination status
el_estimator_core

Core Empirical Likelihood Estimator
el_extract_strata_factor

Extract a strata factor from a survey.design object
el_log_solving

Log a short solver progress note
el_log_banner

Log a step banner line
el_lambda_W

Compute lambda_W from C_const and W
el_dataframe

Empirical likelihood for data frames (NMAR)
el_log_detailed_diagnostics

Log detailed diagnostics
el_resolve_auxiliaries

EL auxiliary design resolution and population means
el_core_eta_state

Core eta-state computation for EL engines
el_log_variance_header

Log variance header and result
el_masses

EL masses and probabilities from denominators
el_log_solver_config

Log solver configuration
el_compute_variance

Variance driver for EL (bootstrap or none)
el_log_final

Log final summary
el_mean

Mean from probability masses
el_log_weight_diagnostics

Log weight diagnostics
el_run_solver

Solver orchestration with staged policy
el_prepare_inputs

Prepare EL inputs for IID and survey designs
el_log_data_prep

Log data prep summary
el_prepare_nleqslv

Prepare nleqslv top-level args and control
exptilt

Exponential tilting estimator
engine_name

Canonical engine name
new_nmar_engine_el

Construct EL Engine Object
el_log_trace

Log a short trace message with the chosen level
merge_nleqslv_top

Prefer explicit solver_args over control-provided top-level args
el_log_start_values

Log starting values
exptilt_nonparam_engine

Nonparametric exponential tilting (EM) engine for NMAR
enforce_nonneg_weights

Enforce (near-)nonnegativity of weights
generate_conditional_density

Generate conditional density
nmar_get_el_denom_floor

EL denominator floor (global, consistent)
el_utils_aux

EL utility helpers
fitted.nmar_result

Default fitted values for NMAR results
el_survey

Empirical likelihood for survey designs (NMAR)
exptilt_engine

Exponential tilting (ET) engine for NMAR estimation
format.nmar_engine

One-line formatter for NMAR engines
engine_config

Extract engine configuration
el_validate_matrix

Validate matrix columns for NA and zero variance
new_nmar_result

Construct Result Object (parent helper)
nmar_fmt_num

Format a number with fixed decimal places using nmar.digits
new_nmar_result_el

Construct EL Result Object
nmar_format_call_line

Format an abridged call line for printing
el_validate_design_spec

Validate design spec dimensions
nmar_result_s3_parent

Parent S3 surface for NMAR results
nmar_get_digits

Resolve global digits setting for printing
exptilt_nonparam

Nonparametric Exponential Tilting (Internal Generic)
prepare_nmar_scaling

Prepare scaled matrices and moments (low-level)
polish_households

Polish Household Budget Data with Simulated Nonignorable Nonresponse
formula.nmar_result

Default formula for NMAR results
nmar_scaling_infra

Shared scaling infrastructure for NMAR engines
nmar_result_get_estimate

Internal helpers for nmar_result objects
extract_nleqslv_top

Extract top-level nleqslv arguments from a control-like list
sanitize_nleqslv_control

Sanitize nleqslv control list for compatibility
run_engine.nmar_engine_el

Run method for EL engine
nmar_get_numeric_settings

NMAR numeric settings
print.summary_nmar_result

Print method for summary.nmar_result
summary.nmar_result

Summary method for nmar_result
summary.nmar_result_el

Summary method for EL results
se

Extract standard error for NMAR results
shared_weighted_gram

Weighted linear algebra helpers
nmar_engine_helpers

S3 helpers for NMAR engine objects
logit_family

Construct a logit response family bundle
nmar

Not Missing at Random (NMAR) Estimation
glance.nmar_result

Glance summary for NMAR results
print.nmar_engine

Print method for NMAR engines
validate_nleqslv_top

Validate top-level nleqslv arguments (coerce invalid to defaults)
validate_nmar_engine_el

Validate EL Engine Settings
riddles_case2

Riddles Simulation, Case 2: Exponential Mean
print.nmar_result_el

Print method for EL results
riddles_case1

Riddles Simulation, Case 1: Linear Mean
tidy.nmar_result

Tidy summary for NMAR results
summary.nmar_result_exptilt

Summary method for Exponential Tilting results (engine-specific)
print.nmar_result_exptilt

Print method for Exponential Tilting results (engine-specific)
unscale_coefficients

Unscale regression coefficients and covariance
voting

Aggregated Exit Poll Data for Gangdong-Gap (2012)
scale_aux_multipliers

Map unscaled auxiliary multipliers to scaled space
trim_weights

Trim weights by capping and proportional redistribution
riddles_case4

Riddles Simulation, Case 4: Cubic Mean
validate_nmar_result

Validate nmar_result structure
weights.nmar_result

Extract weights from an `nmar_result`
vcov.nmar_result

Variance-covariance for base NMAR results
validate_and_apply_nmar_scaling

Validate and apply scaling (engine-friendly)
scale_coefficients

Map unscaled coefficients to scaled space
print.nmar_result

Print method for nmar_result
riddles_case3

Riddles Simulation, Case 3: Sine Wave Mean
probit_family

Construct a probit response family bundle
validate_data

Validate Data for NMAR Analysis
apply_nmar_scaling

Apply scaling to a matrix using a recipe
bootstrap_variance

Shared bootstrap variance helpers
el_build_jacobian_survey

Analytical Jacobian for survey EL system (design-weighted QLS analogue)
confint.summary_nmar_result

Confidence intervals for coefficient table (summary objects)
coef.summary_nmar_result

Coefficient table for summary objects
compute_weighted_stats

Compute (possibly weighted) mean and standard deviation
coef.nmar_result

Default coefficients for NMAR results
bootstrap_variance.default

Default method dispatch (internal safety net)
bootstrap_variance.data.frame

Bootstrap for IID data frames
bootstrap_variance.survey.design

Bootstrap for survey designs via replicate weights
el_build_jacobian

Analytical Jacobian for empirical likelihood
confint.nmar_result

Wald confidence interval for base NMAR results
constraint_summaries

Constraint summaries for EL diagnostics
create_nmar_scaling_recipe

Build a scaling recipe from one or more design matrices