draw_mecc: Draw matched (more) extreme case-control samples

View source: R/extreme_case_control.R

draw_meccR Documentation

Draw matched (more) extreme case-control samples

Description

Draw matched (more) extreme case-control samples

Usage

draw_mecc(
  cohort,
  tau0,
  tau,
  id_name,
  t_name,
  delta_name,
  match_var_names = NULL,
  n_per_case,
  mecc_names = c("y_mecc", "surv", "surv_tau", "set_id_mecc")
)

Arguments

cohort

Cohort data.

tau0

Only subjects who had event before tau0 are considered as cases.

tau

Only subjects who did not have event at or before tau are eligible to be selected as controls. Extreme case-control (ECC) has tau = tau0, and more extreme case-control (MECC) has tau > tau0.

id_name

Name of subject ID.

t_name

Name of time variable.

delta_name

Name of event/censoring indicator.

match_var_names

Name(s) of the match variable(s) in cohort used when drawing a matched MECC sample. A string vector. Default is NULL, i.e., the controls will be sampled randomly.

n_per_case

Number of controls to match to each case.

mecc_names

Names to assign to the following four variables (in sequence): the indicator for extreme events, the estimated survival probability at each time point, the estimated survival probability at tau, and the ID for matched sets (see Details). Default value is c("y_mecc", "surv", "surv_tau", "set_id_mecc").

Details

This function draws a (more) extreme case-control sample from a cohort, with or without matching on confounder(s), with n_per_case controls drawn for each case. Eligible cases are subjects who had the event before time tau0 (and all of them are sampled), and eligible controls are subjects who do not have the event until time tau. This function throws an error if there is not enough controls to select from, otherwise it uses the draw_mcc function to draw a case-control sample.

This package implements the conditional approach described in Section 2.2 of Salim et al 2014, where cases and controls are "individually matched". Therefore, although controls are selected randomly or by frequency matching, n_per_case controls would be randomly assigned to a case to form a "matched set" after drawing the sample.

Value

Returns a data.frame of the (more) extreme case-control sample, with four additional columns as described in parameter mecc_names.

Author(s)

Yilin Ning, Nathalie C Støer

References

  • Salim A, Ma X, Fall K, et al. Analysis of incidence and prognosis from 'extreme' case–control designs. Stat Med 2014; 33: 5388–5398.

  • Støer NC, Salim A, Bokenberger K, et al. Is the matched extreme case–control design more powerful than the nested case–control design?. Stat Methods Med Res 2019; 28(6): 1911-1923.

See Also

llh_mecc_cond, analyse_mecc_cond

Examples

library(SamplingDesignTools)
# Load cohort data
data("cohort_1")
head(cohort_1)
# Draw simple 1:2 more extreme case-control sample, matched on gender.
# Let cases be subjects who had the event within 5 years, and controls be
# selected from those who did not have the event until the 15-th year.
dat_mecc <- draw_mecc(cohort = cohort_1, tau0 = 5, tau = 15,
                      id_name = "id", t_name = "t", delta_name = "y",
                      match_var_names = "gender", n_per_case = 2)
head(dat_mecc)
# Note that the new event indicator, `y_mecc`, is different from the original
# event, `y`, in the cohort:
identical(dat_mecc$y, dat_mecc$y_mecc) # Expect FALSE

nyilin/SamplingDesignTools documentation built on Nov. 20, 2022, 8:07 a.m.