## 2 Materials and Methods
### Statistical Analyses
#### 2.4.2 Development of Calibration Models  
The predictive model used was partial least squares (MPLS) regression, a supervised dimensionality reduction technique for solving regression problems. It extracts latent variables that capture joint variation between the data (X) and a target variable (y). These latent variables are maximally predictive of y, allowing for efficient analysis with reduced dimensions. The involved dimensionality reduction step itself is similar to the principal component analysis (PCA) as the samples are projected on the score space; the difference is that the relationship between the data (independent variables) and a target variable during dimension reduction is considered [41]. This also enables the detection of outliers according to the Mahalanobis distance (H) of each sample from the population center [42]. In the present study, the spectra with an H-distance > 3.5 were considered outliers. Outlying samples were also eliminated for chemical reasons under the T-criterion, i.e., those samples that showed significant differences between the reference value and the predicted value for a T-value \(\geq\) 2.5 [43].  
The number of latent variables was chosen to minimize calibration and cross-validation errors and was different depending on the constituent to be calibrated. For this work, a maximum of 9 latent variables were prefixed for the generation of the models, and a maximum of two passes were carried out to eliminate spectral and chemical outliers using the H- and T-criteria, respectively. The predictive ability of the model was tested by cross-validation. In analytical problems with the number samples similar to those available in this study (n \(\leq\) 60), leave-one-out cross-validation (LOO CV) is often recommended [44] without the need for external validation. However, LOO CV is computationally heavy in the processing of large data sets (i.e., large number of data points per spectrum), such as those delivered by the NIRFlex N-500 [45]. Alternatively, the k-fold CV approach is less computationally expensive than LOO CV and even more robust against overfitting when each sample is represented by one observable (averaged spectra). As demonstrated by [PERSON] et al. [45], k-fold cross-validation delivers consistent results; however, the selected number of folds might be meaningful when different spectrometers are evaluated. Therefore, a more sophisticated approach was employed in this study with the model internally validated using a 6-fold CV, as the processed spectral data did not present any major problems given the sample size and relative homogeneity of the data set. The choice of the cross-validation method--within a reasonable range of folds considering the sample count (e.g., 4 to 7 folds)--should not affect the final estimate of the optimal model complexity and, consequently, the choice of a 6-fold CV grants proper validity to the results. Additionally, calibration was carried out six times, according to the number of groups, and internal validation was performed each time by a group of samples that was not taken into account in the model. The resulting performance of the predictions was compared by the highest multiple correlation coefficient (R-squared, RSQ) and the lowest standard error of calibration and cross-validation (SEC and SECV).