Plot metrics of an aba model summary
Usage
aba_plot_metric(
model_summary,
metric = NULL,
axis = c("predictor", "outcome", "group"),
coord_flip = FALSE,
include_basic = TRUE,
sort = FALSE,
facet_labels = TRUE,
palette = "jama",
plotly = FALSE
)
Arguments
- model_summary
an aba model summary. The object to plot - this should be the result of an
aba_summary()
call.- metric
string. The metric to plot.
- axis
string. Specifies the x axis variable, color/fill variable, and facet variable in that order. Should be a vector of length three that includes only "predictor", "outcome", and "group" as values.
- coord_flip
logical. Whether to flip the x and y axes. This can be useful when there are a large amount of predictor sets and you want to view metrics vertically.
- include_basic
logical. Whether to include basic predictor.
- sort
logical. Whether to sort axis labels by metric value
- facet_labels
logical. Whether to include facet labels or not.
- palette
string. Which ggpubr palette to use. See
ggpubr::set_palette
.- plotly
logical. Whether to use plot.ly instead of standard ggplot. Defaults to false. Using ggplotly can be useful if you want interactivity on web pages.
Examples
# fit aba model
model <- aba_model() %>%
set_data(adnimerge %>% dplyr::filter(VISCODE == 'bl')) %>%
set_groups(everyone()) %>%
set_outcomes(ConvertedToAlzheimers, CSF_ABETA_STATUS_bl,
.labels=c('Conversion to AD', 'CSF Abeta Status')) %>%
set_predictors(
PLASMA_ABETA_bl, PLASMA_PTAU181_bl, PLASMA_NFL_bl,
c(PLASMA_ABETA_bl, PLASMA_PTAU181_bl, PLASMA_NFL_bl),
.labels = c('A','T','N','ATN')
) %>%
set_stats(stat_glm(std.beta=TRUE)) %>%
fit()
#> Error in !is.null(.labels) && (.labels == "self"): 'length = 4' in coercion to 'logical(1)'
# summarise aba model to calculate metrics
model_summary <- model %>% aba_summary()
#> Error in eval(expr, envir, enclos): object 'model' not found
# plot the metrics using default (defaults to AUC)
metric_plot <- model_summary %>% aba_plot_metric()
#> Error in eval(expr, envir, enclos): object 'model_summary' not found
# coord flip
metric_plot2 <- model_summary %>% aba_plot_metric(coord_flip=TRUE)
#> Error in eval(expr, envir, enclos): object 'model_summary' not found
# compare predictor sets within each outcome instead of the opposite
metric_plot3 <- model_summary %>%
aba_plot_metric(axis = c('outcome','predictor', 'group'))
#> Error in eval(expr, envir, enclos): object 'model_summary' not found