aba_plot_coef | R Documentation |
Plot coefficients of an aba model summary
aba_plot_coef(
model_summary,
term_labels = NULL,
axis = c("term", "predictor", "outcome", "group"),
coord_flip = FALSE,
include_covariates = TRUE,
sort = FALSE,
facet_labels = TRUE,
facet_axis = TRUE,
palette = c("jama", "nature", "lancet", "none"),
plotly = FALSE
)
model_summary |
an aba model summary. The object to plot - this should be the
result of an |
term_labels |
list. A list where name is equal to a term variable and value is equal to the label you want to replace it with in the plot. Useful to exchange variable names with labels. Rememeber that terms are the data variables/columns which make up predictors. |
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_covariates |
logical. Whether to include covariates |
sort |
logical. Whether to sort axis labels by coefficient value |
facet_labels |
logical. Whether to include facet labels. |
facet_axis |
logical. Whether to keep axis segment/labels for all facets or whether to remove them for facets. |
palette |
string. Which ggpubr palette to use. See |
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. |
a ggplot of the specified aba model summary coefficients
# 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()
# 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)
# add term labels
term_labels <- list(
'PLASMA_ABETA_bl' = 'Plasma Abeta',
'PLASMA_PTAU181_bl' = 'Plasma P-tau',
'PLASMA_NFL_bl' = 'Plasma NfL'
)
coef_plot2 <- model_summary %>% aba_plot_coef(coord_flip = TRUE,
term_labels = term_labels)
# compare predictor coefficients across outcomes
coef_plot3 <- model_summary %>%
aba_plot_coef(
axis = c('outcome', 'predictor','term','group'), coord_flip=TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.