data(mtcars)
# When working with real data, increase the value of the `niters` and
# `num.trees` parameters to obtain trustworthy results.
# \donttest{
# Function to make sure proper number of cores is specified for multithreading
safe_num_threads <- function(n) {
available <- parallel::detectCores()
if (n > available) available else n
}
# Pooled p-values
set.seed(789)
out_pooled <- shadow_vimp(
data = mtcars, outcome_var = "vs",
niters = c(10, 20, 30), num.trees = 30,
num.threads = safe_num_threads(1)
)
# The following 3 lines of code produce identical plots
plot_vimps(shadow_vimp_out = out_pooled, pooled = TRUE, text_size = 4)
plot_vimps(shadow_vimp_out = out_pooled, text_size = 4)
plot_vimps(shadow_vimp_out = out_pooled)
# Plot only top 3 covariates with the lowest p-values
plot_vimps(shadow_vimp_out = out_pooled, filter_vars = 3)
#' # Do not display p-values on the plot
plot_vimps(shadow_vimp_out = out_pooled, p_val_labels = FALSE)
# Change the size of displayed p-values
plot_vimps(shadow_vimp_out = out_pooled, text_size = 6)
# Change the position of the legend, available options: "right", "left",
# "top","bottom", "none"
plot_vimps(shadow_vimp_out = out_pooled, legend.position = "bottom")
plot_vimps(shadow_vimp_out = out_pooled, legend.position = "left")
# Remove the legend
plot_vimps(shadow_vimp_out = out_pooled, legend.position = "none")
# Remove the subplot that displays the relationship between FWER, FDR, and
# unadjusted p-values
plot_vimps(shadow_vimp_out = out_pooled, helper_legend = FALSE)
# Change colours of the boxes
plot_vimps(shadow_vimp_out = out_pooled, category_colors = c(
"FWER conf." = "#EE2617FF",
"FDR conf." = "#F2A241FF",
"Unadjusted conf." = "#558934FF",
"Not significant" = "#0E54B6FF"
))
# Per variable p-values plot
out_per_var <- shadow_vimp(
data = mtcars, outcome_var = "vs",
niters = c(10, 20, 30), num.trees = 30,
method = "per_variable", num.threads = safe_num_threads(1)
)
# Set pooled to `FALSE`, otherwise the function will throw an error.
plot_vimps(shadow_vimp_out = out_per_var, pooled = FALSE)
# }
Run the code above in your browser using DataLab