make_knn_strata {nncc} | R Documentation |
Make case-control strata using k nearest neighbors (knn)
Description
Select a pre-defined number of controls for each case based on calculated distances between cases and controls.
Usage
make_knn_strata(
expvar,
matchvars,
df,
rmvars = data.frame(exp_var = character(), rm_vars = character(), stringsAsFactors =
FALSE),
casevar = "case",
ncntls = 250,
metric = "gower",
silent = FALSE
)
Arguments
expvar |
A character - the name of the exposure variable in |
matchvars |
Character vector - what are the variables to match on. Note that the function automatically excludes the the exposure variable. |
df |
A dataframe that contains the case-control data. |
rmvars |
A data frame that lists variables to be excluded from matching for each exposure. For details, please see the vignette of this package. |
casevar |
A character - what is the name of the variable indicating case status (1 = case, 0 = control) |
ncntls |
An integer to specify number of controls to find for each case (k in knn). |
metric |
A character to specify a metric for measuring distance between
a case and a control. See |
silent |
Suppress exposure info useful for *apply/loop implementations? |
Details
For more information, please refer to the vignette using
browseVignettes("nncc")
.
Value
A list of data frames with a length
of number of exposures of
interest.