Case-control sampling of expanded data for the sequence of emulated trials
Source:R/sampling.R
case_control_sampling_trials.RdArguments
- 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 = TRUEorseparate_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)