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

424

Version

1.5.1

License

Apache License (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Craig Gower-Page

Last Published

October 14th, 2025

Functions in rbmi (1.5.1)

as_analysis

Construct an analysis object
as_indices

Convert indicator to index
as_ascii_table

as_ascii_table
as_class

Set Class
as_dataframe

Convert object to dataframe
as_draws

Creates a draws object
apply_delta

Applies delta adjustment
antidepressant_data

Antidepressant trial data
as_imputation

Create an imputation object
as_cropped_char

as_cropped_char
check_ESS

Diagnostics of the MCMC based on ESS
as_mmrm_formula

Create MMRM formula
char2fct

Convert character variables to factor
as_mmrm_df

Creates a "MMRM" ready dataset
assert_variables_exist

Assert that all variables exist within a dataset
as_stan_fragments

Conversion of Character Vector into Stan Code Block List
as_stan_array

As array
as_strata

Create vector of Stratas
as_simple_formula

Creates a simple formula object from a string
as_model_df

Expand data.frame into a design matrix
compute_sigma

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

Completion of the Control Options List
delta_template

Create a delta data.frame template
control

Control the computational details of the imputation methods
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's)
draws

Fit the base imputation model and get parameter estimates
d_lagscale

Calculate delta from a lagged scale coefficient
check_mcmc

Diagnostics of the MCMC
clear_model_cache

Clear Model Cache
check_hmc_diagn

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

Extract imputed dataset
extract_params

Extract parameters from a MMRM model
extract_imputed_dfs

Extract imputed datasets
extract_draws

Extract draws from a stanfit object
find_stan_file

Find Stan File
extract_covariates

Extract Variables from string vector
expand

Expand and fill in missing data.frame rows
eval_mmrm

Evaluate a call to mmrm
extract_data_nmar_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)
ensure_rstan

Ensure rstan exists
fit_mcmc

Fit the base imputation model using a Bayesian approach
get_bootstrap_stack

Creates a stack object populated with bootstrapped samples
get_draws_mle

Fit the base imputation model on bootstrap samples
format_method_descriptions

Format method descriptions
get_delta_template

Get delta utility variables
fit_mmrm

Fit a MMRM model
getStrategies

Get imputation strategies
generate_data_single

Generate data for a single group
get_ESS

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

Derive conditional multivariate normal parameters
get_pattern_groups_unique

Get Pattern Summary
get_pattern_groups

Determine patients missingness group
get_example_data

Simulate a realistic example dataset
get_visit_distribution_parameters

Derive visit distribution parameters
get_mmrm_sample

Fit MMRM and returns parameter estimates
get_session_hash

Get session hash
get_pool_components

Expected Pool Components
get_ests_bmlmi

Von Hippel and Bartlett pooling of BMLMI method
get_jackknife_stack

Creates a stack object populated with jackknife samples
get_stan_model

Get Compiled Stan Object
impute_internal

Create imputed datasets
has_class

Does object have a class ?
imputation_list_single

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

Create a valid imputation_single object
ife

if else
impute

Create imputed datasets
imputation_df

Create a valid imputation_df object
impute_data_individual

Impute data for a single subject
imputation_list_df

List of imputations_df
impute_outcome

Sample outcome value
is_num_char_fact

Is character, factor or numeric
is_absent

Is value absent
is_char_fact

Is character or factor
invert

invert
is_in_rbmi_development

Is package in development mode?
invert_indexes

Invert and derive indexes
locf

Last Observation Carried Forward
is_char_one

Is single character
is_valid_covariance_prior

Check for Valid Covariance and Prior Combination
longDataConstructor

R6 Class for Storing / Accessing & Sampling Longitudinal Data
pool_bootstrap_percentile

Bootstrap Pooling via Percentiles
make_rbmi_cluster

Create a rbmi ready cluster
par_lapply

Parallelise Lapply
mcse_internal

Internal MCSE Computations
pool_bootstrap_normal

Bootstrap Pooling via normal approximation
method

Set the multiple imputation methodology
parametric_ci

Calculate parametric confidence intervals
pool

Pool analysis results obtained from the imputed datasets
ls_design

Calculate design vector for the lsmeans
lsmeans

Least Square Means
random_effects_expr

Construct random effects formula
print.draws

Print draws object
print.analysis

Print analysis object
pool_internal

Internal Pool Methods
prepare_stan_data

Prepare input data to run the Stan model
prepare_prior_params

Prepare Prior Parameters for Covariance Model Prior Distribution
print.imputation

Print imputation object
progressLogger

R6 Class for printing current sampling progress
pval_percentile

P-value of percentile bootstrap
prepare_init_vals

Preparation of Initial Values for MCMC Sampler
sample_mvnorm

Sample random values from the multivariate normal distribution
sample_ids

Sample Patient Ids
sample_list

Create and validate a sample_list object
rbmi-settings

rbmi settings
rubin_rules

Combine estimates using Rubin's rules
remove_if_all_missing

Remove subjects from dataset if they have no observed values
rubin_df

Barnard and Rubin degrees of freedom adjustment
rbmi-package

rbmi: Reference Based Multiple Imputation
record

Capture all Output
recursive_reduce

recursive_reduce
split_dim

Transform array into list of arrays
simulate_test_data

Create simulated datasets
simulate_data

Generate data
simulate_dropout

Simulate drop-out
scalerConstructor

R6 Class for scaling (and un-scaling) design matrices
sort_by

Sort data.frame
set_vars

Set key variables
simulate_ice

Simulate intercurrent event
sample_single

Create object of sample_single class
set_simul_pars

Set simulation parameters of a study group.
transpose_samples

Transpose samples
strategies

Strategies
string_pad

string_pad
transpose_imputations

Transpose imputations
str_contains

Does a string contain a substring
validate

Generic validation method
theta_to_cor

Convert Transformed Correlation to Correlation
split_imputations

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

Transpose results object
validate.is_mar

Validate is_mar for a given subject
validate.analysis

Validate analysis objects
validate_analyse_pars

Validate analysis results
validate.stan_data

Validate a stan_data object
theta_to_cs_cor

Convert Transformed Compound Symmetry Correlation to Correlation
validate.draws

Validate draws object
validate.sample_single

Validate sample_single object
validate.ivars

Validate inputs for vars
validate.simul_pars

Validate a simul_pars object
validate_strategies

Validate user specified strategies
validate.references

Validate user supplied references
validate_datalong

Validate a longdata object
validate.sample_list

Validate sample_list object
adjust_trajectories

Adjust trajectories due to the intercurrent event (ICE)
Stack

R6 Class for a FIFO stack
adjust_trajectories_single

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

Implements an Analysis of Covariance (ANCOVA)
ancova

Analysis of Covariance
QR_decomp

QR decomposition
add_class

Add a class
adjust_dimensions

Adjust Dimensions of Prior Parameters for Stan Usage
STAN_BLOCKS

List of Stan Blocks
analyse

Analyse Multiple Imputed Datasets