Skip to contents

A way to visualize the results of the model is to plot the summaries of the linear predict draws, along the summarized data. This function uses the draws to plot the percentiles along the median. The number of percentiles can be specified by the user using the argument `.width`. When variability is too high, it might be better to use only low percentiles, otherwise it is not possible to distinguish the curves.

Usage

plot_posterior_estimates(
  results_estimates_global,
  stats_from_data,
  column_days = "days_after_treatment",
  column_conditions = "treatment",
  column_vals = "log10tf",
  .width = c(0.25, 0.5),
  xlab = "Days after treatment",
  ylab = expression("log"[10] * "(Total flux (photons/sec))"),
  title = paste0("Global bayesian estimates plotted with the average log10 total flux",
    " for each condition.\nThe ribbons correspond to the 25%",
    " and 50% credible interval of the linear predictor"),
  base_size = 20
)

Arguments

results_estimates_global

Output from add_linpred_draws from tidybayes

stats_from_data

Output from get_stats_from_data

column_days

Name of the column where days are indicated

column_conditions

Name of the column where conditions are indicated

column_vals

Name of the measurement column to be used

.width

Vector with the bands for the credible intervals

xlab

Title for xlab

ylab

Title for ylab

title

Title for the plot

base_size

Base size for ggplot2::theme_bw

Value

A ggplot2 object

Examples

if (FALSE) { # \dontrun{
library(brms)
library(biogrowleR)

# first get the model
fit_01 <- brms::brm(
    log10tf ~ days_after_treatment * treatment + (1 | id),
    data = t110_ivis_long,
    cores = 4,
    iter = 4000,
    prior = c(
        brms::set_prior("normal(7, 2)", class = "Intercept"),
        brms::set_prior("normal(0, 4)", class = "b")
    )
)

# then the dataframe to predict new values from the model
new_df_predict <- biogrowleR::get_df_predict(t110_ivis_long)

# the global estimates
results_estimates_global <- tidybayes::add_linpred_draws(
    object = fit_01,
    newdata = new_df_predict,
    re_formula = NA,
    value = "log10tf"
)

# get the stats so it can be used in the plot later
stats_from_data <- biogrowleR::get_stats_from_data(t110_ivis_long)

plot_posterior_estimates(
    results_estimates_global,
    stats_from_data
)
} # }