plotPosterior: Plotting the (marginal) posterior densities in Bayesian...

View source: R/plotting.R

plotPosteriorR Documentation

Plotting the (marginal) posterior densities in Bayesian analyses

Description

This function plots, univariately, the posterior densities obtained in Bayesian analyses.

Usage

plotPosterior(
  results,
  parameter = 1,
  num.points = 1000,
  plot.rope = TRUE,
  plot.samples = TRUE,
  alpha = NULL,
  ...
)

Arguments

results

A list containing, at least three elements, one named approximate, which is a logical value indicating whether the posterior is a function or a sample, rope, a two dimensional vector with the minimum and maximum values of the rope and posterior, either a one parameter function or a matrix (or data.frame) where each row is a sample and each column a sampled parameter

parameter

Either a string or a number indicating, in case the posterior is approximated, the parameter to be ploted (i.e., the name or the index of a column in the sample matrix)

num.points

Number of points used to plot the functions

plot.rope

A logical value indicating whether the rope has to be plotted or not. Note that not for all parameter the rope makes sense

plot.samples

A logical value. If true, the samples are plotted (only when the posterior is approximate)

alpha

Numeric value for the transparency of the points, only applicable if plot.samples is true

...

Additional parameters to the Rgraphviz function. This is mainly to change the layout of the graph

Details

Note that if the methods are exact (not simulated), the true density can be plotted but, for those cases where the posterior is approximated through sampling, the function will plot a kernel density estimation of the posterior and, thus, the probabilities computed by other functions are not directly the areas under the densities.

Value

An object of class ggplot with the plot

Examples

x <- rnorm(25, 1, 2)
y <- rnorm(25, 1.1, 2)
results <- bCorrelatedTtest(x=x, y=y, rho=0, rope=c(-0.05, 0.05))
plotPosterior(results)


b0rxa/scmamp documentation built on Jan. 17, 2024, 10:49 a.m.