Learn R Programming

IMIFA (version 2.1.5)

G_moments: 1st & 2nd Moments of the Pitman-Yor / Dirichlet Processes

Description

Calculates the a priori expected number of clusters or the variance of the number of clusters under a PYP or DP prior for a sample of size N at given values of the concentration parameter alpha and optionally also the Pitman-Yor discount parameter. Useful for soliciting sensible priors (or fixed values) for alpha or discount under the "IMFA" and "IMIFA" methods for mcmc_IMIFA.

Usage

G_expected(N,
           alpha,
           discount = 0,
           MPFR = TRUE)

G_variance(N, alpha, discount = 0, MPFR = TRUE)

Arguments

N

The sample size.

alpha

The concentration parameter. Must be specified and must be strictly greater than -discount. The case alpha=0 is accommodated. When discount is negative alpha must be a positive integer multiple of abs(discount).

discount

The discount parameter for the Pitman-Yor process. Must be less than 1, but typically lies in the interval [0, 1). Defaults to 0 (i.e. the Dirichlet process). When discount is negative alpha must be a positive integer multiple of abs(discount).

MPFR

Logical indicating whether the high-precision libraries Rmpfr and gmp are invoked, at the expense of run-time. Defaults to TRUE and must be TRUE for G_expected when alpha=0 and G_variance when discount is non-zero. See Note.

Value

The expected number of clusters under the specified prior conditions, or the variance of the number of clusters.

Details

All arguments are vectorised. Users can also consult G_priorDensity in order to solicit sensible priors.

References

De Blasi, P., Favaro, S., Lijoi, A., Mena, R. H., Prunster, I., and Ruggiero, M. (2015) Are Gibbs-type priors the most natural generalization of the Dirichlet process?, IEEE Transactions on Pattern Analysis and Machine Intelligence, 37(2): 212-229.

See Also

G_priorDensity, Rmpfr

Examples

Run this code
# NOT RUN {
G_expected(N=50, alpha=19.23356, MPFR=FALSE)
G_variance(N=50, alpha=19.23356, MPFR=FALSE)

G_expected(N=50, alpha=c(19.23356, 12.21619, 1),
           discount=c(0, 0.25, 0.7300045), MPFR=FALSE)
# require("Rmpfr")
# G_variance(N=50, alpha=c(19.23356, 12.21619, 1),
#            discount=c(0, 0.25, 0.7300045), MPFR=c(FALSE, TRUE, TRUE))

# Examine the growth rate of the DP
DP   <- sapply(c(1, 5, 10), function(i) G_expected(1:200, alpha=i, MPFR=FALSE))
matplot(DP, type="l", xlab="N", ylab="G")

# Examine the growth rate of the PYP
# PY <- sapply(c(0.25, 0.5, 0.75), function(i) G_expected(1:200, alpha=1, discount=i))
# matplot(PY, type="l", xlab="N", ylab="G")

# Other special cases of the PYP are also facilitated
# G_expected(N=50, alpha=c(27.1401, 0), discount=c(-27.1401/100, 0.8054447))
# G_variance(N=50, alpha=c(27.1401, 0), discount=c(-27.1401/100, 0.8054447))
# }

Run the code above in your browser using DataLab