aba_plot_coef: Plot coefficients of an aba model summary

Description Usage Arguments Value Examples

View source: R/aba_plot.R

Description

Plot coefficients of an aba model summary

Usage

1
2
3
4
5
6
7
8
9
aba_plot_coef(
  object,
  x = "term",
  group = "predictor",
  facet = c("outcome", "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.

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 coefficients

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(stat_glm(std.beta=TRUE)) %>%
  fit()

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

# plot the coefficients using default
coef_plot <- model_summary %>% aba_plot_coef(coord_flip=TRUE)

# compare predictor coefficients across outcomes
coef_plot2 <- model_summary %>%
  aba_plot_coef(
    x = 'outcome', group='predictor',
    facet=c('term','group'), coord_flip=TRUE
  )

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