Pipe operator
Description
See magrittr::%>% for details.
Usage
lhs %>% rhs
Arguments
lhs
A value or the magrittr placeholder.
rhs
A function call using the magrittr semantics.
Value
The result of calling 'rhs(lhs)'.
Run Standard CIF Analysis
Description
Given a prepped data list from prep_data_cif , run the standard CIF analysis.
Usage
do_cif_analysis(prepped, tau = 15)
Arguments
prepped
A list returned by prep_data_cif(), containing Treatment and Control.
tau
Numeric, time horizon (e.g. 15 or 29).
Details
- RMLT1 uses parameters (a,b,c) = (0,1,0) for recovery/discharge analysis.
- RMLT2 uses (a,b,c) = (0,0,1) for death analysis.
Value
A list with formatted results for RMLT1 and RMLT2.
Run Weighted CIF Analysis
Description
Given the list from prep_data_weighted_cif , run Weighted RMLT1 (recovery/discharge)
and Weighted RMLT2 (death) at a user-specified time horizon tau.
Usage
do_weighted_cif_analysis(prepped, tau)
Arguments
prepped
A list returned by prep_data_weighted_cif().
tau
Numeric time horizon (e.g., 15 or 29).
Details
- Weighted RMLT1 uses eta=1 for recovery/discharge analysis.
- Weighted RMLT2 uses eta=2 for death analysis.
Value
A list with formatted results for WRMLT1 and WRMLT2.
Longitudinal Severity Scores Dataset
Description
Repeated measurements of ordinal severity scores over time for the same patients in the main_df dataset, with treatment-specific trajectory patterns.
Usage
data(long_df)
Format
A data frame with variable rows per patient:
- PersonID
Patient identifier matching ID in main_df (character)
- OrdinalScore
Severity score on 1-8 scale (numeric)
- RelativeDay
Study day (numeric) starting from day 0 (baseline)
Details
Measurements are taken at scheduled visits: days 0 (baseline), 1, 3, 5, 7, 10, 14, 18, 21, 25, 28. The trajectory follows treatment-specific probabilities: treatment patients have 45 and 15 worsening probability, creating realistic differential clinical progression patterns.
Source
Simulated data using treatment-specific random walk with boundaries
Examples
data(long_df)
data(main_df)
head(long_df)
# See data for first patient
subset(long_df, PersonID == "Patient_001")
# Compare average scores by treatment
long_df %>%
dplyr::left_join(main_df[,c("ID","Treatment")], by=c("PersonID"="ID")) %>%
dplyr::group_by(Treatment) %>%
dplyr::summarise(mean_score = mean(OrdinalScore))
Main Competing Risks Dataset Simulated clinical trial data with competing risks survival outcomes. This dataset follows the structure of Adaptive COVID-19 Treatment Trials (ACTT) with built-in treatment effects for demonstration purposes.
Description
Main Competing Risks Dataset Simulated clinical trial data with competing risks survival outcomes. This dataset follows the structure of Adaptive COVID-19 Treatment Trials (ACTT) with built-in treatment effects for demonstration purposes.
Usage
data(main_df)
Format
A data frame with 150 rows and 7 variables:
- ID
Patient identifier (character)
- TimeToRecovery
Time to recovery event in days (numeric)
- TimeToDeath
Time to death event in days (numeric)
- RecoveryCensoringIndicator
Recovery censoring indicator (0=event observed, 1=censored)
- DeathCensoringIndicator
Death censoring indicator (0=event observed, 1=censored)
- BaselineScore
Baseline severity score, range 4-7 (numeric)
- Treatment
Treatment arm indicator (0=control, 1=treatment)
Details
This is a simulated dataset created for demonstration purposes with realistic treatment effects built in: treatment group has ×ばつ faster recovery times and×ばつ improved survival compared to control. The data represents a clinical trial with competing risks where patients can either recover or die, with administrative censoring at 30 days.
Source
Simulated data based on Weibull distributions with treatment-specific parameters
Examples
data(main_df)
head(main_df)
summary(main_df)
# Compare outcomes by treatment
tapply(main_df$TimeToRecovery, main_df$Treatment, summary)
tapply(main_df$TimeToDeath, main_df$Treatment, summary)
Prepare Data for Standard CIF
Description
Cleans and prepares a single dataset for standard (competing risks) CIF analysis.
Usage
prep_data_cif(
data,
ID = "USUBJID",
TimeToRecovery = "TTRECOV",
TimeToDeath = "TTDEATH",
Recov_Censoring = "RECCNSR",
Death_Censoring = "DTHCNSR",
Treatment = "trt"
)
Arguments
data
A data frame with columns for ID, time to recovery, time to death, recovery censor, death censor, and treatment indicator.
ID
Name of the patient ID column. Default is "USUBJID".
TimeToRecovery
Name of the time-to-recovery column. Default "TTRECOV".
TimeToDeath
Name of the time-to-death column. Default "TTDEATH".
Recov_Censoring
Name of the recovery-censor column. Default "RECCNSR" (0=event,1=censor).
Death_Censoring
Name of the death-censor column. Default "DTHCNSR" (0=event,1=censor).
Treatment
Name of the treatment indicator column (0=control,1=treatment). Default "trt".
Value
A list with:
-
data.w: The processed data frame with columnscn, etime, estatus, etype2, Treatment. -
Treatment: Subset ofdata.wwhereTreatment==1. -
Control: Subset ofdata.wwhereTreatment==0.
Prepare Data for Weighted CIF (Legacy Wrapper)
Description
Convenience wrapper that mirrors the original Part II data
preparation workflow for weighted restricted mean analyses. The function now
delegates to prep_data_weighted_cif2 to provide consistent checks
and support for arbitrary ordinal state definitions.
Usage
prep_data_weighted_cif(
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)
)
Arguments
data_main
A data.frame with ID, TTR, TTD, RECCNSR, DTHCNSR, baseline score, trt, etc.
data_long
A data.frame with repeated clinical scores over time (e.g. ADYC, ORDSCOR).
wID_main
Name of the patient ID column in the main dataset (default "USUBJID").
wTimeToRecovery_main
Name of the time-to-recovery column (default "TTRECOV").
wTimeToDeath_main
Name of the time-to-death column (default "TTDEATH").
wRecov_Censoring_main
Name of the recovery-censor column (default "RECCNSR").
wDeath_Censoring_main
Name of the death-censor column (default "DTHCNSR").
wBaselineScore_main
Name of the baseline ordinal column (default "ordscr_bs").
wTreatment_main
Name of the treatment indicator column (0=control,1=treatment). Default "trt".
wID_long
Name of the patient ID column in the long dataset (default "USUBJID").
wADY_long
Name of the day-since-treatment column in the long dataset (default "ADYC").
wScore_long
Name of the ordinal score column in the long dataset (default "ORDSCOR").
wStates_death
Vector of ordinal states for death weighting (default c(4,5,6,7)).
wWeights_death
Numeric weights, same length as wStates_death (default c(2,1.5,1,0.5)).
wStates_discharge
Vector of states for discharge weighting (default c(4,5,6,7)).
wWeights_discharge
Numeric weights, same length as wStates_discharge (default c(0.5,1,1.5,2)).
Value
See prep_data_weighted_cif2 .
Prepare Data for Weighted CIF
Description
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.
Usage
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)
)
Arguments
data_main
A data.frame with ID, TTR, TTD, RECCNSR, DTHCNSR, baseline score, trt, etc.
data_long
A data.frame with repeated clinical scores over time (e.g. ADYC, ORDSCOR).
wID_main
Name of the patient ID column in the main dataset (default "USUBJID").
wTimeToRecovery_main
Name of the time-to-recovery column (default "TTRECOV").
wTimeToDeath_main
Name of the time-to-death column (default "TTDEATH").
wRecov_Censoring_main
Name of the recovery-censor column (default "RECCNSR").
wDeath_Censoring_main
Name of the death-censor column (default "DTHCNSR").
wBaselineScore_main
Name of the baseline ordinal column (default "ordscr_bs").
wTreatment_main
Name of the treatment indicator column (0=control,1=treatment). Default "trt".
wID_long
Name of the patient ID column in the long dataset (default "USUBJID").
wADY_long
Name of the day-since-treatment column in the long dataset (default "ADYC").
wScore_long
Name of the ordinal score column in the long dataset (default "ORDSCOR").
wStates_death
Vector of ordinal states for death weighting (default c(4,5,6,7)).
wWeights_death
Numeric weights, same length as wStates_death (default c(2,1.5,1,0.5)).
wStates_discharge
Vector of states for discharge weighting (default c(4,5,6,7)).
wWeights_discharge
Numeric weights, same length as wStates_discharge (default c(0.5,1,1.5,2)).
Value
A list containing:
-
data.ws.deathanddata.ws.discharge: Full merged datasets with an addedwUcolumn for (death) or (discharge). -
Treatment.deathandControl.death: Subsets for weighted WRMLT2 (death-focused). -
Treatment.dischargeandControl.discharge: Subsets for weighted WRMLT1 (recovery-focused).