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

285

Version

1.6.0

License

Apache License (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Lukas A. Widmer

Last Published

January 23rd, 2026

Functions in rbmi (1.6.0)

as_draws

Creates a draws object
as_model_df

Expand data.frame into a design matrix
as_simple_formula

Creates a simple formula object from a string
as_mmrm_df

Creates a "MMRM" ready dataset
as_dataframe

Convert object to dataframe
as_mmrm_formula

Create MMRM formula
apply_delta

Applies delta adjustment
antidepressant_data

Antidepressant trial data
as_stan_array

As array
as_stan_fragments

Conversion of Character Vector into Stan Code Block List
as_indices

Convert indicator to index
as_imputation

Create an imputation object
d_lagscale

Calculate delta from a lagged scale coefficient
ensure_rstan

Ensure rstan exists
char2fct

Convert character variables to factor
check_ESS

Diagnostics of the MCMC based on ESS
draws

Fit the base imputation model and get parameter estimates
control

Control the computational details of the imputation methods
as_cropped_char

as_cropped_char
as_class

Set Class
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)
extract_covariates

Extract Variables from string vector
assert_variables_exist

Assert that all variables exist within a dataset
check_hmc_diagn

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

Create vector of Stratas
get_ESS

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

Extract imputed datasets
get_bootstrap_stack

Creates a stack object populated with bootstrapped samples
extract_params

Extract parameters from a MMRM model
find_stan_file

Find Stan File
delta_template

Create a delta data.frame template
fit_mcmc

Fit the base imputation model using a Bayesian approach
get_conditional_parameters

Derive conditional multivariate normal parameters
get_delta_template

Get delta utility variables
get_example_data

Simulate a realistic example dataset
format_method_descriptions

Format method descriptions
fit_mmrm

Fit a MMRM model
get_draws_mle

Fit the base imputation model on bootstrap samples
extract_imputed_df

Extract imputed dataset
check_mcmc

Diagnostics of the MCMC
extract_draws

Extract draws from a stanfit object
get_ests_bmlmi

Von Hippel and Bartlett pooling of BMLMI method
compute_sigma

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

Completion of the Control Options List
get_jackknife_stack

Creates a stack object populated with jackknife samples
get_stan_model

Get Compiled Stan Object
generate_data_single

Generate data for a single group
getStrategies

Get imputation strategies
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)
get_unique_hash

Get unique hash
get_visit_distribution_parameters

Derive visit distribution parameters
get_mmrm_sample

Fit MMRM and returns parameter estimates
get_pattern_groups

Determine patients missingness group
imputation_single

Create a valid imputation_single object
impute

Create imputed datasets
impute_data_individual

Impute data for a single subject
impute_internal

Create imputed datasets
get_pattern_groups_unique

Get Pattern Summary
eval_mmrm

Evaluate a call to mmrm
expand

Expand and fill in missing data.frame rows
get_pool_components

Expected Pool Components
is_valid_covariance_prior

Check for Valid Covariance and Prior Combination
ife

if else
imputation_list_single

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

List of imputations_df
invert_indexes

Invert and derive indexes
imputation_df

Create a valid imputation_df object
is_in_rbmi_development

Is package in development mode?
is_num_char_fact

Is character, factor or numeric
is_absent

Is value absent
mcse_internal

Internal MCSE Computations
method

Set the multiple imputation methodology
is_char_fact

Is character or factor
is_char_one

Is single character
pool

Pool analysis results obtained from the imputed datasets
impute_outcome

Sample outcome value
invert

invert
pool_bootstrap_percentile

Bootstrap Pooling via Percentiles
longDataConstructor

R6 Class for Storing / Accessing & Sampling Longitudinal Data
has_class

Does object have a class ?
pool_internal

Internal Pool Methods
ls_design

Calculate design vector for the lsmeans
pool_bootstrap_normal

Bootstrap Pooling via normal approximation
prepare_stan_data

Prepare input data to run the Stan model
random_effects_expr

Construct random effects formula
make_rbmi_cluster

Create a rbmi ready cluster
lsmeans

Least Square Means
prepare_init_vals

Preparation of Initial Values for MCMC Sampler
locf

Last Observation Carried Forward
rbmi-settings

rbmi settings
prepare_prior_params

Prepare Prior Parameters for Covariance Model Prior Distribution
print.imputation

Print imputation object
print.draws

Print draws object
par_lapply

Parallelise Lapply
parametric_ci

Calculate parametric confidence intervals
rubin_rules

Combine estimates using Rubin's rules
rubin_df

Barnard and Rubin degrees of freedom adjustment
pval_percentile

P-value of percentile bootstrap
record

Capture all Output
progressLogger

R6 Class for printing current sampling progress
recursive_reduce

recursive_reduce
simulate_test_data

Create simulated datasets
simulate_dropout

Simulate drop-out
simulate_ice

Simulate intercurrent event
sample_mvnorm

Sample random values from the multivariate normal distribution
rbmi-package

rbmi: Reference Based Multiple Imputation
sample_single

Create object of sample_single class
scalerConstructor

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

Sort data.frame
validate.analysis

Validate analysis objects
validate

Generic validation method
validate_analyse_pars

Validate analysis results
validate_datalong

Validate a longdata object
sample_ids

Sample Patient Ids
print.analysis

Print analysis object
sample_list

Create and validate a sample_list object
validate.sample_list

Validate sample_list object
set_simul_pars

Set simulation parameters of a study group.
split_imputations

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

Transform array into list of arrays
validate.draws

Validate draws object
string_pad

string_pad
validate.is_mar

Validate is_mar for a given subject
theta_to_cor

Convert Transformed Correlation to Correlation
transpose_imputations

Transpose imputations
validate.simul_pars

Validate a simul_pars object
theta_to_cs_cor

Convert Transformed Compound Symmetry Correlation to Correlation
validate.sample_single

Validate sample_single object
str_contains

Does a string contain a substring
strategies

Strategies
validate.stan_data

Validate a stan_data object
validate_strategies

Validate user specified strategies
remove_if_all_missing

Remove subjects from dataset if they have no observed values
transpose_results

Transpose results object
transpose_samples

Transpose samples
simulate_data

Generate data
set_vars

Set key variables
validate.ivars

Validate inputs for vars
validate.references

Validate user supplied references
STAN_BLOCKS

List of Stan Blocks
Stack

R6 Class for a FIFO stack
QR_decomp

QR decomposition
ancova

Analysis of Covariance
ancova_single

Implements an Analysis of Covariance (ANCOVA)
adjust_trajectories

Adjust trajectories due to the intercurrent event (ICE)
add_class

Add a class
adjust_dimensions

Adjust Dimensions of Prior Parameters for Stan Usage
adjust_trajectories_single

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

Analyse Multiple Imputed Datasets
as_ascii_table

as_ascii_table
as_analysis

Construct an analysis object