Learn R Programming

LoTTA (version 0.1.0)

plot_outcome_CONT: Function that plots the median (or another quantile) of the posterior function of a continous outcome along with the quanatile-based credible interval. The function is plotted on top of the binned input data. To bin the data, the score data is divided into bins of fixed length, then the average outcome in each bin is calculated. The average outcomes are plotted against the average values of the score in the corresponding bins.

Description

Function that plots the median (or another quantile) of the posterior function of a continous outcome along with the quanatile-based credible interval. The function is plotted on top of the binned input data. To bin the data, the score data is divided into bins of fixed length, then the average outcome in each bin is calculated. The average outcomes are plotted against the average values of the score in the corresponding bins.

Usage

plot_outcome_CONT(
  LoTTA_posterior,
  nbins = 100,
  probs = c(0.025, 0.5, 0.975),
  n_eval = 200,
  col_line = "#E69F00",
  size_line = 0.1,
  alpha_interval = 0.35,
  col_dots = "gray",
  size_dots = 3,
  alpha_dots = 0.6,
  col_cutoff = "black",
  title = "Outcome function",
  subtitle = NULL,
  y_lab = "",
  x_lab = expression(paste(italic("x"), " - score")),
  plot.theme = theme_classic(base_size = 14),
  legend.position = "none",
  name_legend = "Legend",
  labels_legend = "median outcome fun.",
  text = element_text(family = "serif"),
  legend.text = element_text(size = 14),
  plot.title = element_text(hjust = 0.5),
  plot.subtitle = element_text(hjust = 0.5),
  ...
)

Value

ggplot2 object

Arguments

LoTTA_posterior
  • output of one of the LoTTA functions (LoTTA_sharp, LoTTA_fuzzy)

nbins
  • number of bins to aggregate the input data

probs
  • list of three quantiles, the first and the last one define the quanatile-based credible interval, the middle value defines the quantile of the posterior function to plot; by default the quantiles correspond to the median posterior function and 95% credible interval probs=c(0.025,0.5,0.975)

n_eval
  • n_eval*range(x) is the number of points at which each posterior function is evaluated, the higher number means slower computing time and a smoother plot; default n_eval=200

col_line
  • the color of the line and the band

size_line
  • thickness of the line

alpha_interval
  • alpha value of the band, lower values correspond to a more transparent color

col_dots
  • color of the dots that correspond to the binned data

size_dots
  • size of the dots that correspond to the binned data

alpha_dots
  • transparency of the dots that correspond to the binned data, lower values correspond to a more transparent color

col_cutoff
  • color of the dotted line at the cutoff

title
  • title of the plot

subtitle
  • subtitle of the plot

y_lab
  • label of the y-axis

x_lab
  • label of the x-axis

plot.theme
  • ggplot2 plot theme (see https://ggplot2.tidyverse.org/reference/ggtheme.html) possibly with additional arguments, it takes the default value plot.theme=theme_classic(base_size = 14),

legend.position
  • position of the legend, refer to ggplot2 manual for the possible values; by default legend is not printed legend.position='none'

name_legend
  • title of the legend

labels_legend
  • the label of the plotted function in the legend

text
  • can be any value that is accepted in the argument text in the theme function of ggplot2 package,refer to ggplot2 manual for the possible values; by default is changes font to a serif one text=element_text(family='serif')

legend.text
  • can be any value that is accepted in the argument legend.text in the theme function of ggplot2 package,refer to ggplot2 manual for the possible values; by default is changes font size to the legend to 14 legend.text=element_text(size = 14)

plot.title
  • can be any value that is accepted in the argument plot.title in the theme function of ggplot2 package,refer to ggplot2 manual for the possible values; by default it centers the plot title plot.title = element_text(hjust = 0.5)

plot.subtitle
  • can be any value that is accepted in the argument plot.subtitle in the theme function of ggplot2 package,refer to ggplot2 manual for the possible values; by default it centers the plot subtitle plot.title = element_text(hjust = 0.5)

...
  • other arguments of the theme function, refer to ggplot2 manual