Learn R Programming

Reference Based Multiple Imputation (rbmi)

Overview

The rbmi package is used for the imputation of missing data in clinical trials with continuous multivariate normal longitudinal outcomes. It supports imputation under a missing at random (MAR) assumption, reference-based imputation methods, and delta adjustments (as required for sensitivity analysis such as tipping point analyses). The package implements both Bayesian and approximate Bayesian multiple imputation combined with Rubin's rules for inference, and frequentist conditional mean imputation combined with (jackknife or bootstrap) resampling.

Installation

The package can be installed directly from CRAN via:

install.packages("rbmi")

Note that the usage of Bayesian multiple imputation requires the installation of the suggested package rstan.

install.packages("rstan")

Usage

The package is designed around its 4 core functions:

  • draws() - Fits multiple imputation models
  • impute() - Imputes multiple datasets
  • analyse() - Analyses multiple datasets
  • pool() - Pools multiple results into a single statistic

The basic usage of these core functions is described in the quickstart vignette:

vignette(topic = "quickstart", package = "rbmi")

Validation

For clarification on the current validation status of rbmi please see the FAQ vignette.

Support

For any help with regards to using the package or if you find a bug please create a GitHub issue

Copy Link

Version

Install

install.packages('rbmi')

Monthly Downloads

860

Version

1.7.1

License

Apache License (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Lukas A. Widmer

Last Published

November 5th, 2026

Functions in rbmi (1.7.1)

apply_delta

Applies delta adjustment
antidepressant_data

Antidepressant trial data
as_draws

Creates a draws object
ancova_group_labels

ANCOVA group level labels
ancova_contrast_name

Name a default ANCOVA treatment-effect contrast
as_dataframe

Convert object to dataframe
as_analysis

Construct an analysis object
as_indices

Convert indicator to index
as_imputation

Create an imputation object
as_cropped_char

as_cropped_char
as_ascii_table

as_ascii_table
compute_sigma

Compute covariance matrix for some reference-based methods (JR, CIR)
as_mmrm_df

Creates a "MMRM" ready dataset
complete_control_bayes

Completion of the Control Options List
char2fct

Convert character variables to factor
as_mmrm_formula

Create MMRM formula
check_ESS

Diagnostics of the MCMC based on ESS
ancova_single

Implements an Analysis of Covariance (ANCOVA)
as_class

Set Class
d_lagscale

Calculate delta from a lagged scale coefficient
extract_covariates

Extract Variables from string vector
delta_template

Create a delta data.frame template
eval_mmrm

Evaluate a call to mmrm
expand

Expand and fill in missing data.frame rows
extract_data_mnar_as_na

Set to NA outcome values that would be MNAR if they were missing (i.e. which occur after an ICE handled using a reference-based imputation strategy)
check_hmc_diagn

Diagnostics of the MCMC based on HMC-related measures.
as_stan_fragments

Conversion of Character Vector into Stan Code Block List
as_stan_array

As array
draws

Fit the base imputation model and get parameter estimates
as_model_df

Expand data.frame into a design matrix
as_strata

Create vector of strata
as_simple_formula

Creates a simple formula object from a string
assert_variables_exist

Assert that all variables exist within a dataset
find_stan_file

Find Stan File
ensure_rstan

Ensure rstan exists
convert_to_imputation_list_df

Convert list of imputation_list_single() objects to an imputation_list_df() object (i.e. a list of imputation_df() objects)
control

Control the computational details of the imputation methods
extract_draws

Extract draws from a stanfit object
extract_imputed_df

Extract imputed dataset
get_conditional_parameters

Derive conditional multivariate normal parameters
formula_has_interaction

Check whether a variable participates in a formula interaction
generate_data_single

Generate data for a single group
getStrategies

Get imputation strategies
extract_params

Extract parameters from a MMRM model
check_mcmc

Diagnostics of the MCMC
extract_imputed_dfs

Extract imputed datasets
get_delta_template

Get delta utility variables
ife

if else
get_example_data

Simulate a realistic example dataset
fit_mcmc

Fit the base imputation model using a Bayesian approach
has_class

Does object have a class ?
get_visit_distribution_parameters

Derive visit distribution parameters
get_jackknife_stack

Creates a stack object populated with jackknife samples
fit_mmrm

Fit a MMRM model
get_ESS

Extract the Effective Sample Size (ESS) from a stanfit object
get_bootstrap_stack

Creates a stack object populated with bootstrapped samples
format_method_descriptions

Format method descriptions
imputation_df

Create a valid imputation_df object
get_unique_hash

Get unique hash
invert_indexes

Invert and derive indexes
imputation_single

Create a valid imputation_single object
impute

Create imputed datasets
get_stan_model

Get Compiled Stan Object
frm_find_and_replace

Recursively find and replace symbols in a language object
impute_outcome

Sample outcome value
invert

invert
longDataConstructor

R6 Class for Storing / Accessing & Sampling Longitudinal Data
impute_internal

Create imputed datasets
get_pattern_groups_unique

Get Pattern Summary
get_pool_components

Expected Pool Components
impute_data_individual

Impute data for a single subject
is_absent

Is value absent
ls_design

Calculate design vector for the lsmeans
is_valid_covariance_prior

Check for Valid Covariance and Prior Combination
locf

Last Observation Carried Forward
get_draws_mle

Fit the base imputation model on bootstrap samples
get_mmrm_sample

Fit MMRM and returns parameter estimates
get_ests_bmlmi

Von Hippel and Bartlett pooling of BMLMI method
imputation_list_df

List of imputation_dfs
is_char_fact

Is character or factor
get_pattern_groups

Determine patients missingness group
is_in_rbmi_development

Is package in development mode?
is_num_char_fact

Is character, factor or numeric
imputation_list_single

A collection of imputation_singles() grouped by a single subjid ID
pool_bootstrap_percentile

Bootstrap Pooling via Percentiles
pool

Pool analysis results obtained from the imputed datasets
make_rbmi_cluster

Create a rbmi ready cluster
lsmeans

Least Square Means
rbmi-settings

rbmi settings
pool_internal

Internal Pool Methods
mcse_internal

Internal MCSE Computations
par_lapply

Parallelise lapply
parametric_ci

Calculate parametric confidence intervals
is_char_one

Is single character
print.analysis

Print analysis object
pool_bootstrap_normal

Bootstrap Pooling via normal approximation
pval_percentile

P-value of percentile bootstrap
progressLogger

R6 Class for printing current sampling progress
rbmi-package

rbmi: Reference Based Multiple Imputation
random_effects_expr

Construct random effects formula
method

Set the multiple imputation methodology
print.imputation

Print imputation object
print.draws

Print draws object
record

Capture all Output
sample_mvnorm

Sample random values from the multivariate normal distribution
prepare_init_vals

Preparation of Initial Values for MCMC Sampler
rubin_df

Barnard and Rubin degrees of freedom adjustment
prepare_prior_params

Prepare Prior Parameters for Covariance Model Prior Distribution
resolve_contrast_weights

Resolve a numeric contrast weight vector to full group-level order
sample_ids

Sample Patient Ids
rubin_orig_df

Original Rubin degrees of freedom approximation
sample_single

Create object of sample_single class
simulate_test_data

Create simulated datasets
simulate_dropout

Simulate drop-out
rubin_rules

Combine estimates using Rubin's rules
sort_by

Sort data.frame
simulate_ice

Simulate intercurrent event
theta_to_cor

Convert Transformed Correlation to Correlation
split_imputations

Split a flat list of imputation_single() into multiple imputation_df()'s by ID
prepare_stan_data

Prepare input data to run the Stan model
string_pad

string_pad
remove_if_all_missing

Remove subjects from dataset if they have no observed values
recursive_reduce

recursive_reduce
split_dim

Transform array into list of arrays
theta_to_cs_cor

Convert Transformed Compound Symmetry Correlation to Correlation
transpose_imputations

Transpose imputations
validate_analyse_pars

Validate analysis results
strategies

Strategies
validate.sample_single

Validate sample_single object
str_contains

Does a string contain a substring
validate_strategies

Validate user specified strategies
validate.sample_list

Validate sample_list object
set_vars

Set key variables
sample_list

Create and validate a sample_list object
set_simul_pars

Set simulation parameters of a study group.
validate.analysis

Validate analysis objects
validate

Generic validation method
validate_datalong

Validate a longdata object
validate.references

Validate user supplied references
validate.ivars

Validate inputs for vars
validate.stan_data

Validate a stan_data object
scalerConstructor

R6 Class for scaling (and un-scaling) design matrices
validate.simul_pars

Validate a simul_pars object
transpose_results

Transpose results object
transpose_samples

Transpose samples
validate.is_mar

Validate is_mar for a given subject
simulate_data

Generate data
validate.draws

Validate draws object
adjust_trajectories

Adjust trajectories due to the intercurrent event (ICE)
add_class

Add a class
STAN_BLOCKS

List of Stan Blocks
analyse

Analyse Multiple Imputed Datasets
ancova

Analysis of Covariance
adjust_trajectories_single

Adjust trajectory of a subject's outcome due to the intercurrent event (ICE)
QR_decomp

QR decomposition
Stack

R6 Class for a FIFO stack
adjust_dimensions

Adjust Dimensions of Prior Parameters for Stan Usage
ancova_contrast_design

Build the ANCOVA contrast design matrix
ancova_resolve_contrasts

Resolve the set of ANCOVA contrasts to compute
ancova_linear_contrast

Compute a single ANCOVA linear contrast
ancova_core

Core ANCOVA Implementation