aba_plot_metric: Plot metrics of an aba model summary

Description Usage Arguments Value Examples

View source: R/aba_plot.R

Description

Plot metrics of an aba model summary

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
aba_plot_metric(
  object,
  metric = NULL,
  x = "predictor",
  group = "outcome",
  facet = "group",
  coord_flip = FALSE,
  palette = "jama",
  plotly = FALSE
)

Arguments

object

an aba model summary. The object to plot - this should be the result of an aba_summary() call.

metric

string. The performance metric to plot (e.g., AIC, AUC, adj.r.squared)

x

string. The model spec factor to use as the x axis. Defaults to predictor sets.

group

string. The model spec factor to use as the group variable in ggplot - this corresponding to "group", "fill", and "color" in ggplot. Defaults to outcome.

facet

string. The model spec factor to use as the group variable in ggplot - this corresponding to "facet_wrap" in ggplot. Defaults to group.

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.

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.

Value

a ggplot of the specified aba model summary metric.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# fit aba model
model <- aba_model() %>%
  set_data(adnimerge %>% dplyr::filter(VISCODE == 'bl')) %>%
  set_groups(everyone()) %>%
  set_outcomes(ConvertedToAlzheimers, CSF_ABETA_STATUS_bl) %>%
  set_predictors(
    PLASMA_ABETA_bl, PLASMA_PTAU181_bl, PLASMA_NFL_bl,
    c(PLASMA_ABETA_bl, PLASMA_PTAU181_bl, PLASMA_NFL_bl)
  ) %>%
  set_stats('glm') %>%
  fit()

# summarise aba model to calculate metrics
model_summary <- model %>% aba_summary()

# plot the metrics using default (defaults to AUC)
metric_plot <- model_summary %>% aba_plot_metric()

# coord flip
metric_plot2 <- model_summary %>% aba_plot_metric(coord_flip=TRUE)

# compare predictor sets within each outcome instead of the opposite
metric_plot3 <- model_summary %>%
  aba_plot_metric(x = 'outcome', group='predictor')

aba documentation built on Dec. 17, 2021, 1:06 a.m.