# Classification Models for Nitrogen Concentration in Hop Leaves Using Digital Image Processing
## 2 Materials and Methods
### Data Analysis
#### 2.6.2 Variable Selection and Discriminant Models  
Following the exploratory analysis, the models were estimated to classify images according to the nitrogen concentration in hop leaves.  
First, it was necessary to define which explanatory variables would be used in the models. To do this, two sets of preliminary variables were defined. The first set (set 1) included variables that exhibited statistically significant differences between groups 1 and 2, while the second set (set 2) included all variables except the normalized color variables NR, NG, and NB. This was carried out for both mobile phone and scanner image data.  
Additional selection was performed based on the multicollinearity of the variables, using the variance inflation factor (VIF). A high VIF value for a variable indicates a strong correlation with the other explanatory variables, suggesting multicollinearity, which can increase uncertainty and complicate model interpretation. A commonly used cut-off point in the literature is 10, above which multicollinearity is considered problematic [20]. A possible solution to this is to exclude the variable with the highest VIF, which should not significantly affect the model, as this variable adds redundant information in the presence of the other variables [31].  
Thus, from the sets of preliminary variables, the final variables were selected using a loop as follows: the VIF value for each explanatory variable was calculated, the variable with the highest VIF was excluded, then the VIF values for the remaining variables were calculated again, and the variable with the highest VIF was excluded, repeating this cycle until all the variables had a VIF value \(<10\). Therefore, two sets of final variables were obtained for use in building the models (two sets for mobile phone images and two for scanner images). The VIF values were calculated using the R faraway package (version 1.0.8) [32].  
The linear discriminant analysis (LDA) and quadratic discriminant analysis (QDA) models were estimated using the MASS package (version 7.3-60) [33]. LDA is a discriminant model that assumes that the classes have multivariate normal distributions and that the variance and covariance matrices are equal between the classes, finding a linear hyperplane that maximizes the separation between the classes. QDA, on the other hand, assumes that the matrices are different between the groups and uses a quadratic function to maximize the separation between them [34]. Thus, the covariance and sample variance matrices of thegroups were compared using the Box's M test to check for possible significant differences (\(p<0.05\)). This was carried out for both the mobile image data and scanner data.  
With the data from the mobile phone images (low-resolution images), an LDA model and a QDA model were built for each set of variables, totaling four models: two LDA models and two QDA models. Similarly, with the data from the scanner images (high re-solution), an LDA model and a QDA model were built for each set of variables, totaling four models: two LDA models and two QDA models. The prior probabilities used were 0.5 for both groups. The general flowchart of the methodology is shown in Figure 3.