Generate censoring logic for scenario A
create_censoring_logics_A(
arms,
treatment,
time_to_treatment,
grace_period,
followup,
clone_censoring = ".censoring",
clone_uncensored_followup = ".fup_uncensored"
)A character vector of length 2. The first element represents a name of the untreated arm, and the second element represents a name of the treated arm.
A name of variable that represents whether each observation was treated or not in observational data. The treatment variable should exists in data frame that the return value of this function will be applied, and the treatment variable value in the data frame should be either 0 and 1, i.e. binary treatment.
A name of variable that represent time to treatment in the observational data. The time-to-treatment variable should exists in data frame that the return value of this function will be applied, and the value in the data frame should be either numeric value or NA if the observation was untreated in the observational data.
A numeric value to represent grace period of treatment. Treatment policy is assumed to be "provide treatment within the grace period."
A name of variable that represent follow up time in the observational data. The follow up time variable should exists in data frame that the return value of this function will be applied, and the follow up time variable value in the data frame should be numeric.
A name of binary indicator variable to be newly created to represent whether the observation violates arm's policy or not. The new variable name should not already exist in the data frame that the return value of this function will be applied, to avoid accidental overwriting.
A name of a variable to be newly created for the strategy-specific follow-up time used by the censoring rules. It equals the observed follow-up time for a clone that remains adherent to its assigned strategy, and the artificial-censoring time for a clone that violates it. The new variable name should not already exist in the data frame that the return value of this function will be applied, to avoid accidental overwriting.
A nested list. The first element of the outer list represents
untreated arm, while the second element of the outer list represents
treated arm. For each element of outer list, the first element of the inner
list represents emulated censoring binary indicator (0/1) that represents
whether the observation violated the arm's policy within the grace period.
The second element of the inner list represents the strategy-specific
follow-up time for the censoring process: observed follow-up for adherent
clones and artificial-censoring time for non-adherent clones. Each element of
the inner list represents a sequence of logics to be passed into
case_when() when creating new variables for the emulated censoring
indicator and follow-up time.
arms <- c("Control", "Surgery")
censoring_logics <- create_censoring_logics_A(
arms,
treatment = "surgery",
time_to_treatment = "timetosurgery",
grace_period = 182.62,
followup = "fup_obs",
clone_censoring = "censoring",
clone_uncensored_followup = "fup_uncensored"
)