Generate clone policy for scenario A
create_policy_A(
arms,
treatment,
time_to_treatment,
grace_period,
outcome,
followup,
clone_outcome = ".outcome",
clone_followup = ".fup"
)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 outcome in the observational data. The outcome variable should exists in data frame that the return value of this function will be applied, and the outcome variable value in the data frame should be either 0 and 1, i.e. binary outcome.
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 variable to be newly created to represent emulated outcome in cloned data frame. 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 variable to be newly created to represent emulated follow up time in cloned data frame. 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 outcome, and the second element of the inner list
represents emulated follow up time. Each element of the inner list
represents a sequence of logics to be passed into case_when() when
creating new variables for emulated outcome and follow up time.
arms <- c("Control", "Surgery")
policies <- create_policy_A(
arms,
treatment = "surgery",
time_to_treatment = "timetosurgery",
grace_period = 182.62,
outcome = "death",
followup = "fup_obs",
clone_outcome = "outcome",
clone_followup = "fup"
)