Skip to contents

[Stable]

Usage

case_control_sampling_trials(
  data_prep,
  p_control = NULL,
  subset_condition,
  sort = FALSE
)

Arguments

data_prep

Result from data_preparation().

p_control

Control sampling probability for selecting potential controls at each follow-up time of each trial.

subset_condition

Expression used to subset() the trial data before case-control sampling.

sort

Sort data before applying case-control sampling to make sure that the resulting data are identical when sampling from the expanded data created with separate_files = TRUE or separate_files = FALSE.

Value

A data.frame or a split() data.frame if length(p_control) > 1. An additional column sample_weight containing the sample weights will be added to the result. These can be included in the models fit with trial_msm().

Details

Perform case-control sampling of expanded data to create a data set of reduced size and calculate sampling weights to be used in trial_msm().

Examples

# If necessary reduce the number of threads for data.table
data.table::setDTthreads(2)

data("te_data_ex")
samples <- case_control_sampling_trials(te_data_ex, p_control = 0.01)