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

363

Version

1.4.1

License

Apache License (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Isaac Gravestock

Last Published

March 3rd, 2025

Functions in rbmi (1.4.1)

as_class

Set Class
as_mmrm_df

Creates a "MMRM" ready dataset
as_imputation

Create an imputation object
as_dataframe

Convert object to dataframe
as_analysis

Construct an analysis object
as_indices

Convert indicator to index
as_ascii_table

as_ascii_table
check_ESS

Diagnostics of the MCMC based on ESS
check_hmc_diagn

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

As array
as_strata

Create vector of Stratas
as_draws

Creates a draws object
as_cropped_char

as_cropped_char
check_mcmc

Diagnostics of the MCMC
compute_sigma

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

Convert character variables to factor
assert_variables_exist

Assert that all variables exist within a dataset
as_simple_formula

Creates a simple formula object from a string
as_model_df

Expand data.frame into a design matrix
as_mmrm_formula

Create MMRM formula
draws

Fit the base imputation model and get parameter estimates
ensure_rstan

Ensure rstan exists
eval_mmrm

Evaluate a call to mmrm
expand

Expand and fill in missing data.frame rows
getStrategies

Get imputation strategies
get_ESS

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

Extract Variables from string vector
fit_mcmc

Fit the base imputation model using a Bayesian approach
get_jackknife_stack

Creates a stack object populated with jackknife samples
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)
fit_mmrm

Fit a MMRM model
get_pattern_groups

Determine patients missingness group
get_mmrm_sample

Fit MMRM and returns parameter estimates
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)
extract_params

Extract parameters from a MMRM model
extract_imputed_dfs

Extract imputed datasets
get_pattern_groups_unique

Get Pattern Summary
get_pool_components

Expected Pool Components
get_session_hash

Get session hash
format_method_descriptions

Format method descriptions
imputation_df

Create a valid imputation_df object
imputation_list_df

List of imputations_df
is_absent

Is value absent
is_char_fact

Is character or factor
has_class

Does object have a class ?
get_draws_mle

Fit the base imputation model on bootstrap samples
ife

if else
imputation_single

Create a valid imputation_single object
is_char_one

Is single character
get_delta_template

Get delta utility variables
imputation_list_single

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

Is package in development mode?
d_lagscale

Calculate delta from a lagged scale coefficient
extract_draws

Extract draws from a stanfit object
delta_template

Create a delta data.frame template
invert

invert
invert_indexes

Invert and derive indexes
extract_imputed_df

Extract imputed dataset
get_bootstrap_stack

Creates a stack object populated with bootstrapped samples
generate_data_single

Generate data for a single group
longDataConstructor

R6 Class for Storing / Accessing & Sampling Longitudinal Data
get_conditional_parameters

Derive conditional multivariate normal parameters
ls_design

Calculate design vector for the lsmeans
make_rbmi_cluster

Create a rbmi ready cluster
lsmeans

Least Square Means
get_ests_bmlmi

Von Hippel and Bartlett pooling of BMLMI method
get_stan_model

Get Compiled Stan Object
get_visit_distribution_parameters

Derive visit distribution parameters
impute_internal

Create imputed datasets
impute_outcome

Sample outcome value
get_example_data

Simulate a realistic example dataset
method

Set the multiple imputation methodology
impute_data_individual

Impute data for a single subject
impute

Create imputed datasets
parametric_ci

Calculate parametric confidence intervals
random_effects_expr

Construct random effects formula
sample_mvnorm

Sample random values from the multivariate normal distribution
sample_list

Create and validate a sample_list object
pval_percentile

P-value of percentile bootstrap
pool

Pool analysis results obtained from the imputed datasets
pool_bootstrap_normal

Bootstrap Pooling via normal approximation
pool_bootstrap_percentile

Bootstrap Pooling via Percentiles
rubin_rules

Combine estimates using Rubin's rules
par_lapply

Parallelise Lapply
print.imputation

Print imputation object
progressLogger

R6 Class for printing current sampling progress
sample_ids

Sample Patient Ids
is_num_char_fact

Is character, factor or numeric
rbmi-package

rbmi: Reference Based Multiple Imputation
rbmi-settings

rbmi settings
print.analysis

Print analysis object
locf

Last Observation Carried Forward
simulate_ice

Simulate intercurrent event
simulate_data

Generate data
simulate_dropout

Simulate drop-out
pool_internal

Internal Pool Methods
record

Capture all Output
prepare_stan_data

Prepare input data to run the Stan model
recursive_reduce

recursive_reduce
str_contains

Does a string contain a substring
split_imputations

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

Create simulated datasets
scalerConstructor

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

Strategies
sample_single

Create object of sample_single class
sort_by

Sort data.frame
split_dim

Transform array into list of arrays
validate.analysis

Validate analysis objects
validate.draws

Validate draws object
validate.sample_single

Validate sample_single object
validate.is_mar

Validate is_mar for a given subject
validate_datalong

Validate a longdata object
string_pad

string_pad
validate.ivars

Validate inputs for vars
validate_strategies

Validate user specified strategies
print.draws

Print draws object
validate_analyse_pars

Validate analysis results
validate.stan_data

Validate a stan_data object
validate

Generic validation method
transpose_samples

Transpose samples
validate.simul_pars

Validate a simul_pars object
transpose_results

Transpose results object
set_vars

Set key variables
transpose_imputations

Transpose imputations
remove_if_all_missing

Remove subjects from dataset if they have no observed values
rubin_df

Barnard and Rubin degrees of freedom adjustment
set_simul_pars

Set simulation parameters of a study group.
validate.sample_list

Validate sample_list object
validate.references

Validate user supplied references
add_class

Add a class
adjust_trajectories

Adjust trajectories due to the intercurrent event (ICE)
QR_decomp

QR decomposition
Stack

R6 Class for a FIFO stack
ancova

Analysis of Covariance
ancova_single

Implements an Analysis of Covariance (ANCOVA)
adjust_trajectories_single

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

Analyse Multiple Imputed Datasets
antidepressant_data

Antidepressant trial data
apply_delta

Applies delta adjustment