Description Usage Arguments Details Author(s) See Also Examples
View source: R/functions-imputation.R
Replace missing values with random numbers.
When using the method = "mean_sd"
, random numbers will be generated
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.
When using the method method = "from_to"
, random numbers between 2 specific values
will be generated.
1 2 3 4 5 6 7 8 | imputeRowMinRand(
x,
method = c("mean_sd", "from_to"),
min_fraction = 1/2,
min_fraction_from = 1/1000,
sd_fraction = 1,
abs = TRUE
)
|
x |
|
method |
method |
min_fraction |
|
min_fraction_from |
|
sd_fraction |
|
abs |
|
For method mean_sd, 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.
For method from_to, imputed values are taken between 2 user defined fractions of the row minimum.
Johannes Rainer, Mar Garcia-Aloy
imputeLCMD
package for more left censored imputation functions.
Other imputation functions:
imputeRowMin()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 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_meansd <- imputeRowMinRand(mat, method = "mean_sd")
mat_imp_fromto <- imputeRowMinRand(mat, method = "from_to")
head(mat)
head(mat_imp_meansd)
head(mat_imp_fromto)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.