Title: | Visualize Draws from the Prior and Posterior Distributions |
---|---|
Description: | Interactive visualization for Bayesian prior and posterior distributions. This package facilitates an animated transition between prior and posterior distributions. Additionally, it splits the distribution into bars based on the provided 'breaks,' displaying the probability for each region. If no 'breaks' are provided, it defaults to zero. |
Authors: | Ignacio Martinez [aut, cre], Linus Marco [aut], Dan Thal [aut] |
Maintainer: | Ignacio Martinez <[email protected]> |
License: | GPL-3 |
Version: | 2.0.0.9000 |
Built: | 2024-11-06 02:39:57 UTC |
Source: | https://github.com/ignacio82/vizdraws |
This function creates a lollipop chart to visualize probabilities.
lollipops( data, plotBackgroundColor = "white", plotBackgroundOpacity = 0.8, title = "Probability of an impact", leftArea = "Negative", rightArea = "Positive", mediumText = 18, bigText = 28, width = NULL, height = NULL, elementId = NULL, logoPath = NULL, logoSize = 100, logoLocation = c("bottom-left", "top-left", "top-right", "bottom-right"), rightAreaText = "A positive impact is not necesarly a large impact.", leftAreaText = "A negative impact is not necesarly a large impact." )
lollipops( data, plotBackgroundColor = "white", plotBackgroundOpacity = 0.8, title = "Probability of an impact", leftArea = "Negative", rightArea = "Positive", mediumText = 18, bigText = 28, width = NULL, height = NULL, elementId = NULL, logoPath = NULL, logoSize = 100, logoLocation = c("bottom-left", "top-left", "top-right", "bottom-right"), rightAreaText = "A positive impact is not necesarly a large impact.", leftAreaText = "A negative impact is not necesarly a large impact." )
data |
A data frame containing the probabilities to visualize. |
plotBackgroundColor |
The background color of the plot. |
plotBackgroundOpacity |
The opacity of the plot background. |
title |
The title of the plot. |
leftArea |
The label for the left area of the plot. |
rightArea |
The label for the right area of the plot. |
mediumText |
The font size for medium text elements. |
bigText |
The font size for big text elements. |
width |
The width of the widget (optional). |
height |
The height of the widget (optional). |
elementId |
The element ID of the widget (optional). |
logoPath |
Logo path. Defaults to |
logoSize |
Logo size. Defaults to |
logoLocation |
Logo location. |
rightAreaText |
The tooltip text for the right area of the plot. |
leftAreaText |
The tooltip text for the left area of the plot. |
The data frame should have three columns: 'name', 'value', and 'color'. The 'name' column specifies the names of the data points, while the 'value' column specifies the corresponding probabilities. The 'color' column specifies the color of each lollipop.
A HTML widget object representing the lollipop chart.
data <- data.frame( Name = c("Outcome 1", "Outcome 2", "Outcome 3"), Prior = c(0.5, 0.5, 0.5), Posterior = c(0.2, 0.6, 0.9) ) lollipops(data, logoPath = 'https://upload.wikimedia.org/wikipedia/commons/b/b8/YouTube_Logo_2017.svg', logoLocation = 'bottom-left')
data <- data.frame( Name = c("Outcome 1", "Outcome 2", "Outcome 3"), Prior = c(0.5, 0.5, 0.5), Posterior = c(0.2, 0.6, 0.9) ) lollipops(data, logoPath = 'https://upload.wikimedia.org/wikipedia/commons/b/b8/YouTube_Logo_2017.svg', logoLocation = 'bottom-left')
Visualize Draws from Prior or Posterior Distributions
vizdraws( prior = NULL, posterior = NULL, MME = 0, threshold = NULL, units = NULL, quantity = FALSE, tense = c("future", "past"), backgroundColor = "#FFFFFF", backgroundOpacity = 0.9, xlab = NULL, breaks = NULL, break_names = NULL, colors = NULL, width = NULL, height = NULL, xlim = NULL, font_scale = 1, display_mode_name = FALSE, title = "", stop_trans = FALSE, percentage = FALSE, elementId = NULL, logoPath = NULL, logoSize = 100, logoLocation = c("bottom-right", "top-left", "top-right", "bottom-left") )
vizdraws( prior = NULL, posterior = NULL, MME = 0, threshold = NULL, units = NULL, quantity = FALSE, tense = c("future", "past"), backgroundColor = "#FFFFFF", backgroundOpacity = 0.9, xlab = NULL, breaks = NULL, break_names = NULL, colors = NULL, width = NULL, height = NULL, xlim = NULL, font_scale = 1, display_mode_name = FALSE, title = "", stop_trans = FALSE, percentage = FALSE, elementId = NULL, logoPath = NULL, logoSize = 100, logoLocation = c("bottom-right", "top-left", "top-right", "bottom-left") )
prior |
(optional) Prior distribution or draws from it. Supported distributions: 'Normal', 'uniform', 'beta', and 'gamma'. Provide either this or the posterior. |
posterior |
(optional) Draws from the posterior distribution. Provide either this or the prior. |
MME |
Minimum meaningful effect. If not provided, MME is set to zero. |
threshold |
If the probability is greater than this threshold, a decision is considered comfortable. |
units |
Optional argument to specify the units of x (e.g., dollars or applications). |
quantity |
Defaults to |
tense |
Either "future" or "past." This is the tense used in the description if quantity is set to TRUE. |
backgroundColor |
Defaults to |
backgroundOpacity |
Defaults to |
xlab |
Defaults to |
breaks |
Defaults to |
break_names |
Defaults to |
colors |
Colors for the left, middle, and right areas. Defaults to c("#e41a1c", "#377eb8", "#4daf4a"). |
width |
Width for shiny. |
height |
Height for shiny. |
xlim |
Defaults to |
font_scale |
Defaults to |
display_mode_name |
Defaults to |
title |
Defaults to |
stop_trans |
Defaults to |
percentage |
Defaults to |
elementId |
Use an explicit element ID for the widget (rather than an automatically generated one). elementID for shiny. |
logoPath |
Logo path. Defaults to |
logoSize |
Logo size. Defaults to |
logoLocation |
Logo location. |
A function to visualize draws from either the prior or posterior distribution, facilitating interpretation and decision-making.
A HTML widget object.
if(interactive()){ set.seed(9782) library(vizdraws) vizdraws(prior = rnorm(100000)) }
if(interactive()){ set.seed(9782) library(vizdraws) vizdraws(prior = rnorm(100000)) }
Output and render functions for using vizdraws within Shiny applications and interactive Rmd documents.
vizdrawsOutput(outputId, width = "100%", height = "100%") rendervizdraws(expr, env = parent.frame(), quoted = FALSE)
vizdrawsOutput(outputId, width = "100%", height = "100%") rendervizdraws(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width , height
|
Must be a valid CSS unit (like |
expr |
An expression that generates a vizdraws |
env |
The environment in which to evaluate |
quoted |
Is |