Learn R Programming

IMIFA (version 1.3.1)

G_priorDensity: Plot Dirichlet / Pitman-Yor process Priors

Description

Plots the prior distribution of the number of clusters under a Dirichlet / Pitman-Yor process prior, for a sample of size N at given values of the concentration parameter alpha and optionally also the discount parameter. Useful for soliciting sensible priors for alpha or suitable fixed values for alpha or discount under the "IMFA" and "IMIFA" methods for mcmc_IMIFA. All arguments are vectorised. Users can also consult G_expected and G_variance in order to solicit sensible priors.

Usage

G_priorDensity(N, alpha, discount = 0L, show.plot = TRUE)

Arguments

N

The sample size.

alpha

The concentration parameter. Must be specified and must be strictly greater than -discount.

discount

The discount parameter for the Pitman-Yor process. Must lie in the interval [0, 1). Defaults to 0 (i.e. the Dirichlet process).

show.plot

Logical indicating whether the plot should be displayed (default = TRUE).

Value

A plot of the prior distribution if show.plot is TRUE. Density values are returned invisibly. Note that the density values may not strictly sum to one in certain cases, as values small enough to be represented as zero may well be returned.

See Also

G_expected, G_variance, Rmpfr

Examples

Run this code
# NOT RUN {
# Plot Dirichlet process priors for different values of alpha
DP <- G_priorDensity(N=50, alpha=c(3, 10, 25))
DP

# Non-zero discount requires loading the "Rmpfr" library
# require("Rmpfr")

# Verify that these alpha/discount values produce Pitman-Yor process priors with the same mean
# G_expected(N=50, alpha=c(19.23356, 6.47006, 1), discount=c(0, 0.47002, 0.7300045))

# Now plot them to examine tail behaviour as discount increases
# PY <- G_priorDensity(N=50, alpha=c(19.23356, 6.47006, 1), discount=c(0, 0.47002, 0.7300045))
# PY
# }

Run the code above in your browser using DataLab