View source: R/zero_replacement_imputation.R
| coda_replacement | R Documentation |
Performs imputation of missing values and/or values below the detection limit in compositional data using an EM algorithm assuming normality on the simplex.
coda_replacement(
X,
DL = NULL,
dl_prop = 0.65,
eps = 1e-04,
parameters = FALSE,
debug = FALSE,
maxit = 500
)
X |
A compositional data set: numeric matrix or data frame where rows represent observations and columns represent parts. |
DL |
An optional matrix or vector of detection limits. If 'NULL', the minimum non-zero value in each column of 'X' is used. |
dl_prop |
A numeric value between 0 and 1 used for initialization in the EM algorithm. |
eps |
Convergence tolerance. |
parameters |
Logical; if 'TRUE', return additional estimated parameters. |
debug |
Logical; if 'TRUE', print the log-likelihood at each iteration. |
maxit |
Maximum number of iterations |
If 'parameters = FALSE', the imputed object with the same format as 'X' ('matrix' or 'data.frame', preserving data-frame subclasses when possible) and preserving original names. If 'parameters = TRUE', a list with the estimated clr mean, clr covariance, and imputed clr coordinates.
X <- matrix(c(
0.00, 0.30, 0.70,
0.20, NA, 0.80,
0.40, 0.60, 0.00,
0.25, 0.25, 0.50,
0.10, 0.30, 0.60
), ncol = 3, byrow = TRUE)
colnames(X) <- c("sand", "silt", "clay")
DL <- c(0.05, 0.05, 0.05)
X_imp <- coda_replacement(X, DL = DL, maxit = 20)
X_imp
set.seed(10)
X <- composition(matrix(rnorm(3*10), ncol = 3))
X[sample(c(TRUE, FALSE), 4*10, replace = TRUE, c(1, 3))] <- NA
params <- coda_replacement(X, parameters = TRUE, debug = TRUE)
names(params)
params$clr_mu
composition(params$clr_h)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.