draw_ncc_cm: Draw counter-matched NCC from cohort

View source: R/counter_match.R

draw_ncc_cmR Documentation

Draw counter-matched NCC from cohort

Description

Draw counter-matched NCC from cohort

Usage

draw_ncc_cm(
  cohort,
  y_name = NULL,
  t_name = NULL,
  match_var_name = NULL,
  include_var_name = NULL,
  ml = 1
)

Arguments

cohort

Cohort data. A data.frame or a matrix with column names.

y_name

Name of the variable in cohort indicating the event-censoring status of each subject, where 1 indicates events. A string.

t_name

Name of the variable in cohort for the time of event or censoring. A string.

match_var_name

Name of the categorical variable in cohort to count-match on, which can be the exposure or the surrogate for the exposure. A string. If a vector is supplied, only the first element will be used.

include_var_name

A string vector containing additional variables in cohort to include in the counter-matched NCC sample. Default is NULL.

ml

Number of subjects to draw from each strata defined by the match variable (including the case). Default is 1.

Value

Returns a data.frame of the counter-matched NCC sample.

Examples

library(SamplingDesignTools)
data("cohort_1")
head(cohort_1)
# Counter-match on binary indicator for age:
cohort_1$age_bin <- as.numeric(cohort_1$age < 50)
ncc_cm_bin <- draw_ncc_cm(cohort = cohort_1, y_name = "y", t_name = "t",
                          match_var_name = "age_bin",
                          include_var_name = c("age", "gender"), ml = 1)
head(ncc_cm_bin, 10)

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