Currently, the only way to generate weights is via multivariable Cox, as described in Maringe et al. 2020

generate_ccw(df, predvars, stop_if_var_not_estimated = FALSE)

Arguments

df

A data.frame with one row per clone per observation period as returned by cast_clones_to_long()

predvars

The variables that will be used to derive weights (subset of those in your data.frame originally). At least one covariate must be used.

stop_if_var_not_estimated

if TRUE, will error if a variable is dropped from the model. Otherwise, will continue and omit the variable from the model. Default is FALSE.

Value

The same data.frame with weights added.

Examples


# Load the toy dataset
data(dummy_data)

# Create clones
clones <- create_clones(dummy_data, 
                        id = "id", 
                        event = "event", 
                        time_to_event = "timetoevent", 
                        exposure = "exposure", 
                        time_to_exposure = "timetoexposure", 
                        ced_window = 100)
#> Updating 4 patients' exposure and time-to-exposure based on CED window

clones_long <- cast_clones_to_long(clones)
clones_long_w <- generate_ccw(clones_long, predvars = c("cov1"))