Learn R Programming

bbricks (version 0.1.1)

marginalLikelihood_bySufficientStatistics.GaussianNIW: Marginal likelihood of a "GaussianNIW" object, usnig sufficient statistics

Description

Generate the marginal likelihood of a set of observations of the following model structure: theta|gamma ~ NIW(gamma) x|theta ~ Gaussian(theta) where theta = (mu,Sigma) is the Gaussian parameter, gamma = (m,k,v,S) is the Normal-Inverse-Wishart(NIW) parameter. The model structure and prior parameters are stored in a "GaussianNIW" object. Marginal likelihood is the likelihood of x|gamma.

Usage

# S3 method for GaussianNIW
marginalLikelihood_bySufficientStatistics(obj, ss, LOG = TRUE, ...)

Arguments

obj

A "GaussianNIW" object.

ss

Sufficient statistics of x. In Gaussian-NIW case the sufficient statistic of sample x is a object of type "ssGaussian", it can be generated by the function sufficientStatistics().

LOG

Return the log density if set to "TRUE".

...

Additional arguments to be passed to other inherited types.

Value

numeric, the marginal likelihood.

References

Murphy, Kevin P. "Conjugate Bayesian analysis of the Gaussian distribution." def 1.22 (2007): 16.

Gelman, Andrew, et al. "Bayesian Data Analysis Chapman & Hall." CRC Texts in Statistical Science (2004).

See Also

@seealso GaussianNIW, marginalLikelihood.GaussianNIW

Examples

Run this code
# NOT RUN {
x <- rGaussian(1000,mu = c(1,1),Sigma = matrix(c(1,0.5,0.5,3),2,2))
obj <- GaussianNIW(gamma=list(m=c(0,0),k=1,v=2,S=diag(2)))
marginalLikelihood(obj = obj,x=x)
## or...
ss <- sufficientStatistics(obj=obj,x=x,foreach = FALSE)
marginalLikelihood_bySufficientStatistics(obj = obj,ss=ss)
# }

Run the code above in your browser using DataLab