Pre-flight validation of data, variable specification, and intercurrent event
data before calling rbmi::draws(). Collects all issues and reports them
together in a single error message.
Arguments
- data
A data.frame containing the analysis dataset.
- vars
A
varsobject as created byrbmi::set_vars().- data_ice
An optional data.frame of intercurrent events. If provided, must contain columns corresponding to
vars$subjid,vars$visit, andvars$strategy. Can be created usingprepare_data_ice().
Value
Invisibly returns TRUE if all checks pass. Throws an error with
collected messages if any issues are found.
Details
The following checks are performed:
datais a data.frameAll columns named in
varsexist indatasubjid,visit, andgroupcolumns are factorsoutcomecolumn is numericCovariate columns have no missing values
Data has one row per subject-visit combination
If
data_iceis provided: correct columns, valid subjects, valid visits, recognised strategies, and at most one row per subject
Recommended Workflow:
Call
validate_data()to check your dataUse
prepare_data_ice()to create ICE data if neededReview missingness with
summarise_missingness()Proceed with
rbmi::draws()for imputation
See also
prepare_data_ice()to create intercurrent event data from flagssummarise_missingness()to understand missing data patternsrbmi::draws()to perform imputation after validation
Examples
library(rbmi)
dat <- data.frame(
USUBJID = factor(rep(c("S1", "S2", "S3"), each = 3)),
AVISIT = factor(rep(c("Week 4", "Week 8", "Week 12"), 3),
levels = c("Week 4", "Week 8", "Week 12")),
TRT = factor(rep(c("Placebo", "Drug A", "Drug A"), each = 3)),
CHG = c(1.1, 2.2, 3.3, 0.5, NA, NA, 1.0, 2.0, NA),
BASE = rep(c(10, 12, 11), each = 3),
STRATA = factor(rep(c("A", "B", "A"), each = 3))
)
vars <- set_vars(
subjid = "USUBJID",
visit = "AVISIT",
group = "TRT",
outcome = "CHG",
covariates = c("BASE", "STRATA")
)
validate_data(dat, vars)