Nearest Neighbors Matching of Case-Control Data
Function to cache long operations
Calculate the pooled strata OR
Distance density plots comparing closest to random choices
Final cleaning of the matched dataset(s)
Fix the strata so they all have at least one case and control
Calculate population attributable fraction using odds ratio
Identify the right threshold
Make analysis set
Make analysis datasets
Make case-control strata using k nearest neighbors (knn)
nncc: nearest-neighbors matching for case-control data
Compare the original strata's distances to the knn version
Plot the OR results
Calculate odds ratios
Show the prediction of the logistic regression model
Ensures controls are unique to avoid possible pseudoreplication issues
Format strata output into CSV
Provides nearest-neighbors matching and analysis of case-control data. Cui, Z., Marder, E. P., Click, E. S., Hoekstra, R. M., & Bruce, B. B. (2022) <doi:10.1097/EDE.0000000000001504>.