Learn R Programming

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

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

368

Version

1.3.1

License

Apache License (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Craig Gower-Page

Last Published

December 11th, 2024

Functions in rbmi (1.3.1)

apply_delta

Applies delta adjustment
QR_decomp

QR decomposition
adjust_trajectories_single

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

Analysis of Covariance
ancova_single

Implements an Analysis of Covariance (ANCOVA)
Stack

R6 Class for a FIFO stack
as_class

Set Class
as_cropped_char

as_cropped_char
adjust_trajectories

Adjust trajectories due to the intercurrent event (ICE)
as_analysis

Construct an analysis object
as_dataframe

Convert object to dataframe
assert_variables_exist

Assert that all variables exist within a dataset
char2fct

Convert character variables to factor
as_draws

Creates a draws object
expand

Expand and fill in missing data.frame rows
analyse

Analyse Multiple Imputed Datasets
as_mmrm_df

Creates a "MMRM" ready dataset
as_ascii_table

as_ascii_table
as_imputation

Create an imputation object
extract_covariates

Extract Variables from string vector
as_model_df

Expand data.frame into a design matrix
as_mmrm_formula

Create MMRM formula
as_simple_formula

Creates a simple formula object from a string
compute_sigma

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

Diagnostics of the MCMC
as_indices

Convert indicator to index
as_stan_array

As array
delta_template

Create a delta data.frame template
as_strata

Create vector of Stratas
check_hmc_diagn

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

Diagnostics of the MCMC based on ESS
ensure_rstan

Ensure rstan exists
draws

Fit the base imputation model and get parameter estimates
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)
eval_mmrm

Evaluate a call to mmrm
extract_imputed_df

Extract imputed dataset
getStrategies

Get imputation strategies
d_lagscale

Calculate delta from a lagged scale coefficient
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_draws

Extract draws from a stanfit object
extract_imputed_dfs

Extract imputed datasets
get_bootstrap_stack

Creates a stack object populated with bootstrapped samples
get_ESS

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

Derive conditional multivariate normal parameters
fit_mmrm

Fit a MMRM model
get_pattern_groups

Determine patients missingness group
get_pool_components

Expected Pool Components
extract_params

Extract parameters from a MMRM model
get_pattern_groups_unique

Get Pattern Summary
generate_data_single

Generate data for a single group
get_stan_model

Get Compiled Stan Object
get_visit_distribution_parameters

Derive visit distribution parameters
fit_mcmc

Fit the base imputation model using a Bayesian approach
get_jackknife_stack

Creates a stack object populated with jackknife samples
is_char_one

Is single character
get_ests_bmlmi

Von Hippel and Bartlett pooling of BMLMI method
get_session_hash

Get session hash
get_mmrm_sample

Fit MMRM and returns parameter estimates
get_example_data

Simulate a realistic example dataset
has_class

Does object have a class ?
get_delta_template

Get delta utility variables
is_in_rbmi_development

Is package in development mode?
imputation_list_single

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

if else
is_num_char_fact

Is character, factor or numeric
locf

Last Observation Carried Forward
impute

Create imputed datasets
get_draws_mle

Fit the base imputation model on bootstrap samples
imputation_single

Create a valid imputation_single object
impute_internal

Create imputed datasets
parametric_ci

Calculate parametric confidence intervals
impute_data_individual

Impute data for a single subject
impute_outcome

Sample outcome value
imputation_df

Create a valid imputation_df object
invert

invert
longDataConstructor

R6 Class for Storing / Accessing & Sampling Longitudinal Data
imputation_list_df

List of imputations_df
is_absent

Is value absent
method

Set the multiple imputation methodology
pool

Pool analysis results obtained from the imputed datasets
ls_design

Calculate design vector for the lsmeans
print.imputation

Print imputation object
is_char_fact

Is character or factor
par_lapply

Parallelise Lapply
pval_percentile

P-value of percentile bootstrap
pool_bootstrap_normal

Bootstrap Pooling via normal approximation
random_effects_expr

Construct random effects formula
invert_indexes

Invert and derive indexes
pool_bootstrap_percentile

Bootstrap Pooling via Percentiles
progressLogger

R6 Class for printing current sampling progress
sample_single

Create object of sample_single class
lsmeans

Least Square Means
scalerConstructor

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

Create a rbmi ready cluster
remove_if_all_missing

Remove subjects from dataset if they have no observed values
rubin_df

Barnard and Rubin degrees of freedom adjustment
pool_internal

Internal Pool Methods
rbmi-package

rbmi: Reference Based Multiple Imputation
prepare_stan_data

Prepare input data to run the Stan model
print.analysis

Print analysis object
record

Capture all Output
set_simul_pars

Set simulation parameters of a study group.
rbmi-settings

rbmi settings
recursive_reduce

recursive_reduce
split_imputations

Split a flat list of imputation_single() into multiple imputation_df()'s by ID
print.draws

Print draws object
set_vars

Set key variables
rubin_rules

Combine estimates using Rubin's rules
validate.is_mar

Validate is_mar for a given subject
str_contains

Does a string contain a substring
transpose_imputations

Transpose imputations
transpose_results

Transpose results object
sample_ids

Sample Patient Ids
sample_list

Create and validate a sample_list object
validate_datalong

Validate a longdata object
validate.ivars

Validate inputs for vars
validate_strategies

Validate user specified strategies
simulate_data

Generate data
sample_mvnorm

Sample random values from the multivariate normal distribution
simulate_ice

Simulate intercurrent event
simulate_test_data

Create simulated datasets
strategies

Strategies
simulate_dropout

Simulate drop-out
sort_by

Sort data.frame
validate.analysis

Validate analysis objects
split_dim

Transform array into list of arrays
transpose_samples

Transpose samples
validate.draws

Validate draws object
validate

Generic validation method
validate.stan_data

Validate a stan_data object
validate.references

Validate user supplied references
validate.sample_list

Validate sample_list object
string_pad

string_pad
validate.sample_single

Validate sample_single object
validate.simul_pars

Validate a simul_pars object
validate_analyse_pars

Validate analysis results
add_class

Add a class
antidepressant_data

Antidepressant trial data