R: Joint Density Plot

joint.density.plot {LaplacesDemon} | R Documentation

## Joint Density Plot

### Description

This function plots the joint kernel density from samples of two marginal posterior distributions.

### Usage

    joint.density.plot(x, y, Title=NULL, contour=TRUE, color=FALSE, Trace=NULL)

### Arguments

`x,y` | These are vectors consisting of samples from two marginal posterior distributions, such as those output by `LaplacesDemon` in components `Posterior1` (all samples) or `Posterior2` (stationary samples).
`Title` | This is the title of the joint posterior density plot.
`contour` | This logical argument indicates whether or not contour lines will be added to the plot. `contour` defaults to `TRUE`.
`color` | This logical argument indicates whether or not color will be added to the plot. `color` defaults to `FALSE`.
`Trace` | This argument defaults to `NULL`, in which case it does not trace the exploration of the joint density. To trace the exploration of the joint density, specify `Trace` with the beginning and ending iteration or sample. For example, to view the trace of the first ten iterations or samples, specify `Trace=c(1,10)`.

### Details

This function produces either a bivariate scatterplot that may have kernel density contour lines added, or a bivariate plot with kernel density-influenced colors, which may also have kernel density contour lines added. A joint density plot may be more informative than two univariate density plots.

The `Trace` argument allows the user to view the exploration of the joint density, such as from MCMC chain output. An efficient algorithm jumps to random points of the joint density, and an inefficient algorithm explores more slowly. The initial point of the trace (which is the first element passed to `Trace`) is plotted with a green dot. The user should consider plotting the joint density of the two marginal posterior distributions with the highest `IAT`, as identified with the `PosteriorChecks` function, since these are the two least efficient MCMC chains. Different sequences of iterations may be plotted. This ‘joint trace plot’ may show behavior of the MCMC algorithm to the user.

### Author(s)

Statisticat, LLC. software@bayesian-inference.com

### See Also

`IAT`, `LaplacesDemon`, and `PosteriorChecks`

### Examples

    library(LaplacesDemon)
    X <- rmvn(1000, runif(2), diag(2))
    joint.density.plot(X[,1], X[,2], Title="Joint Density Plot",
         contour=TRUE, color=FALSE)
    joint.density.plot(X[,1], X[,2], Title="Joint Density Plot",
         contour=FALSE, color=TRUE)
    joint.density.plot(X[,1], X[,2], Title="Joint Density Plot",
         contour=TRUE, color=TRUE)
    joint.density.plot(X[,1], X[,2], Title="Joint Trace Plot",
         contour=FALSE, color=TRUE, Trace=c(1,10))

[Package LaplacesDemon version 16.1.1 Index]