# Optimized Weighted Nearest Neighbours Matching Algorithm for Control Group Selection
## 1 Introduction  
Observational studies are widely applied data analysis methods mainly used in healthcare [1; 2; 3; 4; 5]. In these studies, the effect of a treatment, a risk factor, or other intervention is evaluated by performing a comparative analysis. The comparison is based on the analysis of the results of two groups, the treated and the untreated (control) groups, and the investigator has no control over the assignment of the subjects into the groups. Such analyses are carried out, for example, when the effectiveness of a drug for a particular disease is to be assessed (e.g., how effective a drug is at treating heart failure). In this case, the case group includes patients treated with the drug under investigation, while the control group includes patients who do not receive the drug. The comparison between the two groups can only be made adequately if the groups are similar in terms of the factors influencing the administration of the drug under study (e.g., severity of disease treated, comorbidities, drug sensitivity) and factors influencing the disease under study (in this example, age, lifestyle). For example, if only more severely ill or significantly older patients were selected in the control group, the result of the comparative analysis would be misleading. When the treated and the control groups are unbalanced to each other, the result of data analysis is often misleading. To get well-balanced treated and control groups, the bias of those covariates that simultaneously affect group assignment and the output variable of the study should be avoided. For balancing the two groups, different matching techniques were proposed. The simplest solution is based on stratified matching, but balancing score-based methods can also be used, and pairing of the treated and untreated individuals can also be performed in the \(n\)-dimensional space of the covariates. Propensity score matching (PSM) [6] is the most widely applied balancing score-based matching method for selecting proper individuals into the control group. Despite the widespread use of the PSM method, it has received much criticism, as many articles point to the possible imbalance between the treated and control groups. When individuals are characterized by many covariates, the propensity scores of the individuals are diverse, and the PSM methods achieve a good performance. However, when only a few covariates are considered, and these covariates influence the selection of individuals with similar weighting factors, the PSM methods may result in a less balanced control group. To solve the problem mentioned before, a nearest neighbour-based control group selection method (Weighted Nearest Neighbours Control Group Selection with Error Minimization, WNNEM) was proposed in our previous study [7]. However, the WNNEM method also has some limitations. On the one hand, it cannot handle covariates negatively associated with the treatment assignment and, on the other hand, it uses local optimization to find the proper control group. In the current research, we aimed to eliminate these limitations. As a result, this article proposes a novel control group selection algorithm named Weighted Nearest Neighbours Control Group Selection with Simulated Annealing (WNNSA), which uses a global metaheuristic optimization method, namely simulated annealing for finding the best pairing of individuals. Furthermore, concerning the effect of the covariates, the proposed algorithm can also handle both positive and negative covariates. The new model can not only deal with variables related positively to the outcome variable (e.g., the risk of heart failure increases with age) but also variables negatively related to the outcome variable (e.g., taking an ACE inhibitor reduces the risk of heart failure). The efficiency of the newly proposed method will be presented by Monte Carlo simulations on two datasets.