Learn R Programming

rbmiUtils (version 0.3.0)

tidy_pool_obj: Tidy and Annotate a Pooled Object for Publication

Description

This function processes a pooled analysis object of class pool into a tidy tibble format. It adds contextual information, such as whether a parameter is a treatment comparison or a least squares mean, dynamically identifies visit names from the parameter column, and provides additional columns for parameter type, least squares mean type, and visit.

Usage

tidy_pool_obj(pool_obj)

Value

A tibble containing the processed pooled analysis results with the following columns:

parameter

Original parameter name from the pooled object

description

Human-readable description of the parameter

visit

Visit name extracted from parameter (if applicable)

parameter_type

Either "trt" (treatment comparison) or "lsm" (least squares mean)

lsm_type

For LSM parameters: "ref" (reference) or "alt" (alternative)

est

Point estimate

se

Standard error

lci

Lower confidence interval

uci

Upper confidence interval

pval

P-value

Arguments

pool_obj

A pooled analysis object of class pool, typically obtained from rbmi::pool() after calling analyse_mi_data().

Details

The function dynamically processes the parameter column by separating it into components (e.g., type of estimate, reference vs. alternative arm, and visit), and provides informative descriptions in the output.

Workflow:

  1. Prepare data and run imputation with rbmi

  2. Analyse with analyse_mi_data()

  3. Pool with rbmi::pool()

  4. Tidy with tidy_pool_obj() for publication-ready output

See Also

  • rbmi::pool() which creates the pool objects this function tidies

  • analyse_mi_data() to analyse imputed datasets

  • format_results() for additional formatting options

Examples

Run this code
# Example usage:
library(dplyr)
library(rbmi)

data("ADMI")
N_IMPUTATIONS <- 100
BURN_IN <- 200
BURN_BETWEEN <- 5

# Convert key columns to factors
ADMI$TRT <- factor(ADMI$TRT, levels = c("Placebo", "Drug A"))
ADMI$USUBJID <- factor(ADMI$USUBJID)
ADMI$AVISIT <- factor(ADMI$AVISIT)

# Define key variables for ANCOVA analysis
 vars <- set_vars(
  subjid = "USUBJID",
  visit = "AVISIT",
  group = "TRT",
  outcome = "CHG",
  covariates = c("BASE", "STRATA", "REGION")  # Covariates for adjustment
 )

# Specify the imputation method (Bayesian) - need for pool step
method <- rbmi::method_bayes(
  n_samples = N_IMPUTATIONS,
  control = rbmi::control_bayes(
    warmup = BURN_IN,
    thin = BURN_BETWEEN
    )
  )

# Perform ANCOVA Analysis on Each Imputed Dataset
ana_obj_ancova <- analyse_mi_data(
  data = ADMI,
  vars = vars,
  method = method,
  fun = ancova,  # Apply ANCOVA
  delta = NULL   # No sensitivity analysis adjustment
)

pool_obj_ancova <- pool(ana_obj_ancova)
tidy_df <- tidy_pool_obj(pool_obj_ancova)

# Print tidy data frames
print(tidy_df)

Run the code above in your browser using DataLab