Prepares merged competing-risks and longitudinal severity data for weighted restricted mean analyses. The routine removes patients with zero follow-up or missing baseline severity, handles discharge-to-die cases, merges the longitudinal trajectory, and computes user-specified weighted time summaries for death-focused and discharge-focused analyses.
prep_data_weighted_cif2(
data_main,
data_long,
wID_main = "USUBJID",
wTimeToRecovery_main = "TTRECOV",
wTimeToDeath_main = "TTDEATH",
wRecov_Censoring_main = "RECCNSR",
wDeath_Censoring_main = "DTHCNSR",
wBaselineScore_main = "ordscr_bs",
wTreatment_main = "trt",
wID_long = "USUBJID",
wADY_long = "ADYC",
wScore_long = "ORDSCOR",
wStates_death = c(4, 5, 6, 7),
wWeights_death = c(2, 1.5, 1, 0.5),
wStates_discharge = c(4, 5, 6, 7),
wWeights_discharge = c(0.5, 1, 1.5, 2)
)A list containing:
data.ws.death and data.ws.discharge: Full merged datasets
with an added wU column for (death) or (discharge).
Treatment.death and Control.death: Subsets for weighted WRMLT2 (death-focused).
Treatment.discharge and Control.discharge: Subsets for weighted WRMLT1 (recovery-focused).
A data.frame with ID, TTR, TTD, RECCNSR, DTHCNSR, baseline score, trt, etc.
A data.frame with repeated clinical scores over time (e.g. ADYC, ORDSCOR).
Name of the patient ID column in the main dataset (default "USUBJID").
Name of the time-to-recovery column (default "TTRECOV").
Name of the time-to-death column (default "TTDEATH").
Name of the recovery-censor column (default "RECCNSR").
Name of the death-censor column (default "DTHCNSR").
Name of the baseline ordinal column (default "ordscr_bs").
Name of the treatment indicator column (0=control,1=treatment). Default "trt".
Name of the patient ID column in the long dataset (default "USUBJID").
Name of the day-since-treatment column in the long dataset (default "ADYC").
Name of the ordinal score column in the long dataset (default "ORDSCOR").
Vector of ordinal states for death weighting (default c(4,5,6,7)).
Numeric weights, same length as wStates_death (default c(2,1.5,1,0.5)).
Vector of states for discharge weighting (default c(4,5,6,7)).
Numeric weights, same length as wStates_discharge (default c(0.5,1,1.5,2)).