Learn R Programming

TrialEmulation (version 0.0.4.2)

case_control_sampling_trials: Case-control sampling of expanded data for the sequence of emulated trials

Description

[Stable]

Usage

case_control_sampling_trials(
  data_prep,
  p_control = NULL,
  subset_condition,
  sort = 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().

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.

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

Run this code
# 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)

Run the code above in your browser using DataLab