View source: R/functions-imputation.R
imputeRowMinRand | R Documentation |
Replace missing values with random numbers from a normal distribution based
on (a fraction of) the row min and a standard deviation estimated from the
linear relationship between row standard deviation and mean of the full data
set. Parameter sd_fraction
allows to further reduce the estimated
standard deviation.
imputeRowMinRand(x, min_fraction = 1/2, sd_fraction = 1, abs = TRUE)
x |
|
min_fraction |
|
sd_fraction |
|
abs |
|
Imputed values are taken from a normal distribution with mean being a
user defined fraction of the row minimum and the standard deviation
estimated for that mean based on the linear relationship between row
standard deviations and row means in the full matrix x
.
To largely avoid imputed values being negative or larger than the real
values, the standard deviation for the random number generation is estimated
ignoring the intercept of the linear model estimating the relationship
between standard deviation and mean. If abs = TRUE
NA
values are
replaced with the absolute value of the random values.
Johannes Rainer
imputeLCMD
package for more left censored imputation functions.
Other imputation functions: imputeRowMin
library(faahKO)
data("faahko")
xset <- group(faahko)
mat <- groupval(xset, value = "into")
## Estimate the relationship between row sd and mean. The standard deviation
## of the random distribution is estimated on this relationship.
mns <- rowMeans(mat, na.rm = TRUE)
sds <- apply(mat, MARGIN = 1, sd, na.rm = TRUE)
plot(mns, sds)
abline(lm(sds ~ mns))
mat_imp <- imputeRowMinRand(mat)
head(mat)
head(mat_imp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.