Learn R Programming

bbricks (version 0.1.4)

dPosterior.CatDirichlet: Density function of the posterior distribution of a "CatDirichlet" object

Description

Generate the the density value of the posterior distribution of the following structure: $$pi|alpha \sim Dir(alpha)$$ $$x|pi \sim Categorical(pi)$$ Where Dir() is the Dirichlet distribution, Categorical() is the Categorical distribution. See ?dDir and dCategorical for the definitions of these distribution. The model structure and prior parameters are stored in a "CatDirichlet" object. Posterior density is the density function of Dir(pi|alpha).

Usage

# S3 method for CatDirichlet
dPosterior(obj, pi, LOG = TRUE, ...)

Arguments

obj

A "CatDirichlet" object.

pi

matrix or a numeric vector. When pi is a matrix, each row is an observation. When pi is a vector, it will be treated as only one observation.

LOG

Return the log density if set to "TRUE".

...

Additional arguments to be passed to other inherited types.

Value

numeric vector, the posterior densities for each row of pi.

See Also

CatDirichlet, rPosterior.CatDirichlet

Examples

Run this code
# NOT RUN {
obj <- CatDirichlet(gamma=list(alpha=runif(26),uniqueLabels = letters))
dPosterior(obj = obj,pi = runif(26))
dPosterior(obj = obj,pi = matrix(runif(26*10),nrow = 10))
# }

Run the code above in your browser using DataLab