View source: R/counter_match.R
draw_ncc_cm | R Documentation |
Draw counter-matched NCC from cohort
draw_ncc_cm( cohort, y_name = NULL, t_name = NULL, match_var_name = NULL, include_var_name = NULL, ml = 1 )
cohort |
Cohort data. A |
y_name |
Name of the variable in |
t_name |
Name of the variable in |
match_var_name |
Name of the categorical variable in |
include_var_name |
A string vector containing additional variables in
|
ml |
Number of subjects to draw from each strata defined by the match variable (including the case). Default is 1. |
Returns a data.frame
of the counter-matched NCC sample.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.