plot_2fac {mixgb} | R Documentation |
Bar plots for two imputed factor variables
Description
Plot observed values versus m sets of imputed values for two specified numeric variables using ggplot2.
Usage
plot_2fac(
imputation.list,
var.fac1,
var.fac2,
original.data,
true.data = NULL,
color.pal = NULL
)
Arguments
imputation.list |
A list of |
var.fac1 |
A factor variable |
var.fac2 |
A factor variable |
original.data |
The original data with missing data |
true.data |
The true data without missing values. This is generally unknown in practice. If the true data is known (e.g., in cases where it is generated by simulation), it can be specified in this argument. The output will then have an extra panel called |
color.pal |
A vector of hex color codes for the observed and m sets of imputed values panels. The vector should be of length |
Value
Scatter plots for two numeric/integer variable
Examples
# create some extra missing values in factor variables "HSSEX" and "DMARETHN"
nhanes3_NA <- createNA(nhanes3, var.names = c("HSSEX", "DMARETHN"), p = 0.1)
# obtain m multiply datasets
params <- list(max_depth = 3, subsample = 0.8, nthread = 2)
imputed.data <- mixgb(data = nhanes3_NA, m = 3, xgb.params = params, nrounds = 30)
# plot the multiply imputed values for variables "HSSEX" versus "DMARETHN"
plot_2fac(
imputation.list = imputed.data, var.fac1 = "DMARETHN", var.fac2 = "HSSEX",
original.data = nhanes3_NA
)