Skip to contents

A plot of a sample of model fit draws from the posterior distribution from the expected mean and median quantile intervals.

Usage

plot_posterior_draws(
  model,
  newdata = NULL,
  treatment_variable = NULL,
  treatment_units = NULL,
  treatment_from = NULL,
  treatment_to = NULL,
  response_variable = NULL,
  response_units = NULL,
  title = "Dose-Response Posterior Draws",
  n = 50,
  point_size = 0.75,
  jitter_height = 0,
  jitter_width = 0
)

Arguments

model

bpfit object resulting from fitting a BayesPharma model

newdata

data.frame or NULL of new data to use for predictions. Default data.frame with each predictor and treatment variable.

treatment_variable

character or NULL. If NULL the treatment variable name will be looked up in the model. The treatment variable the model$data or newdata if supplied must have a column corresponding to the treatment variable.

treatment_units

character or NULL. If NULL the treatment units will be looked up in the model. The treatment units will be used to label the X-axis of the plot.

treatment_from

numeric or NULL, for the lower bound on the treatment range. If NULL, then use the (finite) lower bound of the treatment variable in the model data.

treatment_to

numeric or NULL, for the upper bound on the treatment range. If NULL, then use the (finite) upper bound of the treatment variable in the model data.

response_variable

string or NULL. If NULL the response variable name will be looked up in the model. The response variable the model$data or newdata if supplied must have a column corresponding to the response variable.

response_units

character or NULL. If NULL the response units will be looked up in the model. The response units will be used to label the Y-axis of the plot.

title

character name for the plot

n

numeric value of the number of draws to show.

point_size

numeric. ggplot2::geom_jitter() point size.

jitter_height

numeric. the height distance between overlapping points.

jitter_width

numeric. the width distance between overlapping points.

Value

ggplot2::ggplot object.

Examples

if (FALSE) {
  # Consider a model named my_model and data named my_data with a column
  # named predictors containing multiple different perturbations.
  plot_posterior_draws(
    model = my_model,
    newdata = my_data,
    predictors_col_name = "predictors",
    lower = -12,
    upper = -3,
    n = 50,
    facet_var = predictors,
    jitter_width = 0.10,
    title = "Dose-Response Posterior Draws",
    xlab = "Log[Molar]",
    ylab = "Response")
}