density_ratio | R Documentation |

Compute the ratio of two densities at given points based on draws of the corresponding distributions.

density_ratio(x, y = NULL, point = 0, n = 4096, ...)

`x` |
Vector of draws from the first distribution, usually the posterior distribution of the quantity of interest. |

`y` |
Optional vector of draws from the second distribution, usually the
prior distribution of the quantity of interest. If |

`point` |
Numeric values at which to evaluate and compare the densities.
Defaults to |

`n` |
Single numeric value. Influences the accuracy of the density
estimation. See |

`...` |
Further arguments passed to |

In order to achieve sufficient accuracy in the density estimation, more draws than usual are required. That is you may need an effective sample size of 10,000 or more to reliably estimate the densities.

A vector of length equal to `length(point)`

. If `y`

is
provided, the density ratio of `x`

against `y`

is returned. Else,
only the density of `x`

is returned.

x <- rnorm(10000) y <- rnorm(10000, mean = 1) density_ratio(x, y, point = c(0, 1))

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.