Skip to contents

Multiplicative replacement of missing values.

Usage

# S4 method for CompositionMatrix
replace_NA(x, value)

Arguments

x

A CompositionMatrix object.

value

A numeric vector giving the replacement values.

Value

An CompositionMatrix object, where all missing values have been replaced.

References

Martín-Fernández, J. A., Barceló-Vidal, C. & Pawlowsky-Glahn, V. (2003). Dealing with Zeros and Missing Values in Compositional Data Sets Using Nonparametric Imputation. Mathematical Geology, 35(3): 253-278. doi:10.1023/A:1023866030544 .

See also

Other imputation methods: missing, replace_zero()

Author

N. Frerebeau

Examples

## Data from Martín-Fernández et al. 2003
X <- data.frame(
  X1 = c(0.0000, 0.1304, 0.1963),
  X2 = c(0.1250, 0.3151, NA),
  X3 = c(0.1237, NA, NA),
  X4 = c(0.7253, 0.2002, 0.0819),
  X5 = c(0.0260, 0.3543, 0.0114)
)

## Coerce to a compositional matrix
Y <- as_composition(X)

## Replace zeros
Z <- replace_NA(Y, value = 0.2)
Z
#> <CompositionMatrix: 3 x 5>
#>          X1      X2     X3        X4         X5
#> 1 0.0000000 0.12500 0.1237 0.7253000 0.02600000
#> 2 0.1043200 0.25208 0.2000 0.1601600 0.28344000
#> 3 0.4066989 0.20000 0.2000 0.1696823 0.02361878