# Techniques for Robust Imputation in Incomplete Two-Way Tables
## 2 Material and Methods  
### Missing Value Imputation Using the SVD-Method SVD88  
The method consists of an updated version of the imputation system of [PERSON] [10] with some minor changes reported in the literature that improve its performance [11]. Consider a matrix \(\mathbf{Y}\left(n\times p\right)\) with elements \(y_{ij}\)\((i=1,\ldots n;\ j=1,\ldots p)\) and \(p>n\) (if \(p<n\) the matrix should be first transposed). First, suppose there is just one missing value \(y_{ij}\) in \(\mathbf{Y}\). Then, the \(i\)-th row from \(\mathbf{Y}\) is deleted and the SVD for the \(((n-1)\times p)\) resulting matrix \(\mathbf{Y}^{(-i)}\) is calculated as \(\mathbf{Y}^{(-i)}=\overline{\mathbf{U}\mathbf{D}\mathbf{V}}^{T}\), \(\overline{\mathbf{U}}=(\overline{u}_{sh})\), \(\overline{\mathbf{V}}=(\overline{v}_{sh})\), \(\overline{\mathbf{D}}=\left(\overline{d}_{1},\ldots,\overline{d}_{p}\right)\). The next step is to delete the \(j\)-th column from \(\mathbf{Y}\) and obtain the SVD for the \((n\times(p-1))\) matrix \(\mathbf{Y}_{(-i)}\) as \(\mathbf{Y}_{(-j)}=\widetilde{\mathbf{U}}\widetilde{\mathbf{D}}\widetilde{\mathbf{V}}^{T}\), \(\widetilde{\mathbf{U}}=(\widetilde{u}_{sh})\), \(\widetilde{\mathbf{V}}=(\widetilde{v}_{sh})\), \(\widetilde{\mathbf{D}}=\left(\widetilde{d}_{1},\ldots,\widetilde{d}_{p-1}\right)\). The matrices \(\overline{\mathbf{U}}\), \(\overline{\mathbf{V}}\), \(\widetilde{\mathbf{U}}\) and \(\widetilde{\mathbf{V}}\) are orthonormal, while \(\widetilde{\mathbf{D}}\) and \(\overline{\mathbf{D}}\) are diagonal. Now, combining the two SVDs, \(\mathbf{Y}^{(-i)}\) and \(\mathbf{Y}_{(-j)}\), the imputed value is given by:  
\[\hat{y}_{ij}=\sum_{h=1}^{H}\widetilde{u}_{ih}\left(\widetilde{d}_{h}\sqrt{p/( p-1)}\right)^{\frac{1}{2}}\overline{v}_{jh}\left(\overline{d}_{h}\sqrt{n/(n-1)} \right)^{\frac{1}{2}} \tag{1}\]  
where H is the optimal number of components of the SVD that can be found by cross-validation methods adapted for matrices with missing data and available in the R statistical environment [13]. In this work, the \"_bcv_\" package was used, which has implemented cross-validation for incomplete matrices using an EM algorithm ([13]; available from CRAN; see [[https://cran.r-project.org/web/packages/bcv/index.html](https://cran.r-project.org/web/packages/bcv/index.html)]([https://cran.r-project.org/web/packages/bcv/index.html](https://cran.r-project.org/web/packages/bcv/index.html)), accessed on 25 June 2021).  
When there is more than one missing value, an iterative scheme is required as follows. Initially, all missing values are replaced by their respective column means, giving a completed matrix \(\mathbf{Y}\) and then the columns are standardized by subtracting \(m_{j}\) and dividing the result by \(s_{j}\) (where \(m_{j}\) and \(s_{j}\) represent the mean and the standard deviation of the \(j\)-th column calculated only from the observed values). Using the standardized matrix, the imputation for each missing value is recalculated using the Equation (1). Finally, the matrix \(\mathbf{Y}\) is returned to its original scale, \(y_{ij}=m_{j}+s_{j}\hat{y}_{ij}\). Then, the process is iterated until stability is achieved in the imputations (i.e., when the values in two successive iterations agree to within a desired level of accuracy). In order to avoid convergence problems, a parity check should be done in each iteration by matching the sign of \(\left(\widetilde{u}_{ih}\left(\widetilde{d}_{h}\sqrt{p/(p-1)}\right)^{\frac{ 1}{2}}\right)\left(\overline{v}_{jh}\left(\overline{d}_{h}\sqrt{n/(n-1)} \right)^{\frac{1}{2}}\right)\) in Equation (1) to the sign of \(u_{ih}d_{h}v_{jh}\) obtained from the SVD of the \(\mathbf{Y}\) matrix for each \(h=1,\ldots,H\)[11].  
Pseudocode  
1. \(\mathbf{Y}<\)- incomplete matrix.
2. \(\mathbf{Y}^{*}<\)- initial completed matrix (columns mean and standardisation).
3. \(\hat{y}_{ij}<\)- Imputation update (Equation (1)), \(\forall(i,j)\) with missing values.
4. Return to step ii. until stability is achieved in the imputations.