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

Description Usage Arguments Value See Also Examples

View source: R/Categorical_Inference.r

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

1
2
## S3 method for class '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

1
2
3
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))

bbricks documentation built on July 8, 2020, 7:29 p.m.