## 2 Materials and Methods
### Methods  
#### 2.2.1. _Imputation Methods_  
* missForest  
The missForest algorithm uses an iterative imputation scheme by training a random forest (RF) on observed values in a first step, followed by predicting the missing values and then proceeding iteratively. [PERSON] [17] chose RF because it can handle mixed-type data and is known to perform very well under barren conditions like high dimensions, complex interactions, and nonlinear data structures. Unlike the algorithm of RF, missForest directly predicts the missing values using an RF trained on the observed parts of the data set.  
Figure 7: Monthly missing data distribution in several stations: (**a**) Marco da Curra, (**b**) Guitiriz, (**c**) Mabegondo, (**d**) CIS Ferrol, (**e**) Punta Candieira, (**f**) Fragavella, (**g**) Sambreixo, (**h**) Serra da Faladioira, (**i**) Corno do Boi, (**j**) [PERSON] [18] defines RF as a combination of tree predictors such that each tree depends on the values of a random vector sampled independently and with the same distribution for all trees in the forest. The generalization error for forests converges to a limit as the number of trees in the forest becomes large. The algorithm in R was computed using a _variablewise_ argument as TRUE, the data matrix was supplied, and the number of iterations varied depending on the case.
* MICE In MICE, each variable has its imputation model. More specifically, continuous data can be used: pmm (predictive mean matching), norm (Bayesian linear regression), norm.nob (linear regression, nonBayesian), mean (unconditional mean imputation) and 2L.norm (two-level linear model) [16]. Predictive mean matching was chosen because this method, compared to other imputation methods, generally imputes less implausible values (e.g., negative rain) and accounts for heteroscedastic data more appropriately [22,23]. The algorithm in R was computed with \(m=5\) as the number of multiple imputations, \(maxit=50\) as the maximum number of iterations, and the random number generator \(seed=500\); it was not necessary to use a predictor matrix because the selection process was conducted previously as will be explained below. To pool the five estimated values, the mean was calculated.
* Amelia II Amelia implements the expectation-maximization with bootstrapping. The algorithm uses the familiar expectation-maximization (EM) algorithm on multiple bootstrapped samples of the original incomplete data to draw values of the complete data parameters. The algorithm then draws imputed values from each set of boostrapped parameters, thereby replacing the missing values with these draws. It also has features to make valid and more accurate imputations for cross-sectional, time series, and time series cross-section data, as well as allows the incorporation of observation and data matrix cell-level prior information [20]. The imputation in time series data is the reason why this multiple imputation method was chosen, thus adding the weather timestamp associated with each rainfall value. The number of multiple imputations was \(m=5\), the parallel argument was set to _multicore_, the lags and leads arguments were set to station columns, and the mean was also calculated to pool the five estimated values.
* IDW (Inverse Distance Weighting) The IDW method estimates the value of the target point based on the values of neighbouring points, with more weight given to points closer to the target point. This method uses the Cartesian coordinates of the target station and uses the inverse distance raised to a power of \(P\) as a weighting factor for the adjacent point values, as shown in Equation (1) [7]: \[z_{p}=\frac{\sum_{i=1}^{n}(\frac{z_{i}}{d_{i}^{i}})}{\sum_{i=1}^{n}(\frac{1}{d_ {i}^{i}})}\] (1) To impute with the IDW algorithm in R, a Euclidean distance matrix was supplied, and the power of \(P\) was set to 2.