## 3 Proposed Method
### Algorithm for Joint Discretization and Grouping  
As follows from the previous section, to solve the problem of joint discretization (for the year variable) and grouping (for the department variable), it is necessary to develop an algorithm that solves the optimization problem (4). This algorithm refers to the so-called wrapping methods [56; 57] that focus on the quality of the estimated model. The existing approaches [58; 59] are designed for classification tasks; that is, they assume that the response is categorical. Therefore, their application to transform a set of exploratory variables in constructing ANOVA models requires discretizing the response, leading to the loss of significant information. The well-known algorithms based on statistical (ChiMerge [60], Chi2 [61]) and information evaluation measure (MDLP [62]) have the same disadvantage. Compared to the problem of discretization, the grouping problem has not been studied so deeply in the literature. Most of the existing algorithms (Sequential Forward Selectionmethod [63], CHAID [64], MODL [65]) solve the grouping problem with a greedy heuristic based on bottom-up categorization. Thus, most of the existing supervised discretization algorithms are designed to solve classification problems, that is, for a categorical response. They are mainly aimed at improving the quality of predicting the response (quality of classification) [66; 67], while our task in the present research is not to predict IQ, but to obtain and interpret estimates of the effects of the explanatory variables. Moreover, the existing discretization algorithms are usually univariate. In this regard, it seems relevant to develop an algorithm for the optimal categorization of several explanatory variables, considering their interrelationships, to build an ANOVA model. Here categorization includes two tasks: Discretization of quantitative variables and grouping of categorical variables. To solve this problem, the algorithm is proposed and studied by the authors of [68], based on a standard supervised agglomerative discretization technique. It is greedy and includes the following steps:  
* Step 1. Set starting intervals by placing each unique value into a separate interval. * Step 2. Calculate the evaluation function Q for each pair of adjacent intervals. * Step 3. Combine the pair with the best Q value (if the stopping condition did not work). * Step 4. Repeat steps 2-3 until no further merging is possible. At step 2, a goodness function is calculated, while simultaneously combining two attributes. For a categorical variable, all possible pairs of factor levels are considered, for a quantitative variable, we consider only adjacent intervals. In addition, a zero index according is assigned to the variable for which the levels are not combined. This is done in case the optimal solution is in combining the levels only for one of the variables. At step 3, the algorithm stops if, after combining, it is not possible to achieve an improvement in the goodness function. At step 4, further merging is considered impossible if all factors have two levels. This described algorithm does not guarantee that an optimal solution will be obtained, because moving along the path that currently seems to be the best, discarding all other options, does not exclude the fact that the discarded path at the current step turns out to be optimal. Most likely, the solution obtained in this way will be locally optimal. Another extreme choice of an optimization algorithm is a complete enumeration of all possible options, which ultimately guarantees a global optimum. However, a full enumeration in the case of several explanatory variables, which involves the joint solution of discretization and more resource-intensive grouping problems, requires unacceptably large computation resources. Based on the above reasoning, in the present work, we have chosen an intermediate version of the algorithm with a partial screening of the best solutions.