Description Usage Arguments Value Author(s) Examples
This function accommodates several methods for single imputation of data. Currently, the following methods are defined:
"imputeData"Applies the mclust native imputation function
imputeData
"missForest"Applies non-parameteric, random-forest based data
imputation using missForest
. Radom forests can
accommodate any complex interactions and non-linear relations in the data. My
simulation studies indicate that this method is preferable to mclust's
imputeData
(see examples).
1 | single_imputation(x, method = "imputeData")
|
x |
A data.frame or matrix. |
method |
Character. Imputation method to apply, Default: 'imputeData' |
A data.frame
Caspar J. van Lissa
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | ## Not run:
library(ggplot2)
library(missForest)
library(mclust)
dm <- 2
k <- 3
n <- 100
V <- 4
# Example of one simulation
class <- sample.int(k, n, replace = TRUE)
dat <- matrix(rnorm(n*V, mean = (rep(class, each = V)-1)*dm), nrow = n,
ncol = V, byrow = TRUE)
results <- estimate_profiles(data.frame(dat), 1:5)
plot_profiles(results)
compare_solutions(results)
# Simulation for parametric data (i.e., all assumptions of latent profile
# analysis met)
simulation <- replicate(100, {
class <- sample.int(k, n, replace = TRUE)
dat <- matrix(rnorm(n*V, mean = (rep(class, each = V)-1)*dm), nrow = n,
ncol = V, byrow = TRUE)
d <- prodNA(dat)
d_mf <- missForest(d)$ximp
m_mf <- Mclust(d_mf, G = 3, "EEI")
d_im <- imputeData(d, verbose = FALSE)
m_im <- Mclust(d_im, G = 3, "EEI")
class_tabl_mf <- sort(prop.table(table(class, m_mf$classification)),
decreasing = TRUE)[1:3]
class_tabl_im <- sort(prop.table(table(class, m_im$classification)),
decreasing = TRUE)[1:3]
c(sum(class_tabl_mf), sum(class_tabl_im))
})
# Performance on average
rowMeans(simulation)
# Performance SD
colSD(t(simulation))
# Plot shows slight advantage for missForest
plotdat <- data.frame(accuracy = as.vector(simulation), model =
rep(c("mf", "im"), n))
ggplot(plotdat, aes(x = accuracy, colour = model))+geom_density()
# Simulation for real data (i.e., unknown whether assumptions are met)
simulation <- replicate(100, {
d <- prodNA(iris[,1:4])
d_mf <- missForest(d)$ximp
m_mf <- Mclust(d_mf, G = 3, "EEI")
d_im <- imputeData(d, verbose = FALSE)
m_im <- Mclust(d_im, G = 3, "EEI")
class_tabl_mf <- sort(prop.table(table(iris$Species,
m_mf$classification)), decreasing = TRUE)[1:3]
class_tabl_im <- sort(prop.table(table(iris$Species,
m_im$classification)), decreasing = TRUE)[1:3]
c(sum(class_tabl_mf), sum(class_tabl_im))
})
# Performance on average
rowMeans(simulation)
# Performance SD
colSD(t(simulation))
# Plot shows slight advantage for missForest
plotdat <- data.frame(accuracy = as.vector(tmp),
model = rep(c("mf", "im"), n))
ggplot(plotdat, aes(x = accuracy, colour = model))+geom_density()
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.