Cannot replace NA value by NIPALS

Hi,

I run nipals to try to replace the NA value in my data. It s not omics data and the variable number is actually low (only 4).


THis is the data matrix:
[1,] 0.0051 -2.2931 1.273327e-03 1.000000e+00
[2,] 0.5850 -0.2328 4.863503e-01 2.618128e-03
[3,] 2.3760 0.3758 8.985543e-01 1.417084e-03
[4,] NA NA 7.892459e+01 1.613350e-05
[5,] 4.4040 0.6438 1.655116e+00 7.693280e-04
[6,] 3.0610 0.4859 1.007731e+00 1.263558e-03
[7,] 133.0000 2.1239 1.049912e+01 1.212790e-04
[8,] 0.0273 -1.5640 5.780848e-02 2.202665e-02
[9,] 3.4380 0.5363 6.535615e-01 1.948290e-03
[10,] 17.5500 1.2443 2.700022e+00 4.715990e-04
[11,] NA NA 2.474982e+01 5.144790e-05
[12,] NA NA 3.126641e+05 4.072510e-09
[13,] 0.8080 -0.0926 2.849912e-01 4.467953e-03
[14,] 1.6120 0.2074 9.381483e-01 1.357277e-03
[15,] 10.9100 1.0378 NA NA
[16,] 2.9070 0.4634 9.264198e-01 1.374460e-03
[17,] 0.0984 -1.0070 2.834711e-02 4.491911e-02
[18,] 0.1958 -0.7082 4.385818e-02 2.903283e-02
[19,] 1.9130 0.2817 5.647530e-01 2.254662e-03

Additionally, I tried with a matrix with 128 variables (4 from the above data and 124 new ones). The new variables actually came from a different experiment and there is no NA in the new added data. But the estimated values by nipals still NA
Is there any mistake in my code or it is due to my data was too small to calculate missing values?

Thanks
P/s When I run the code
nipals.tune = nipals(X.na, reconst = TRUE, ncomp = 10)$eig
It showed an error “unused argument (reconst = TRUE)”

Hi @Hoa,

The nipals function has changed as of 6.16.0. (mixOmics/NEWS.md at master · aljabadi/mixOmics · GitHub). The imputation algorithm now is a separate function. Below is an example code. You can look into ?impute.nipals for more info.

data("nutrimouse")
X <- data.matrix(nutrimouse$lipid)
## add missing values to X to impute and compare to actual values
set.seed(42)
na.ind <- sample(seq_along(X), size = 10)
true.values <- X[na.ind]
X[na.ind] <- NA
X.impute <- impute.nipals(X = X, ncomp = 5)
## compare
round(X.impute[na.ind], 2)
true.values
1 Like