sufficientStatistics.GaussianGaussian {bbricks}R Documentation

Sufficient statistics of a "GaussianGaussian" object

Description

For following model structure:

x \sim Gaussian(mu,Sigma)

mu \sim Gaussian(m,S)

Where Sigma is known. Gaussian() is the Gaussian distribution. See ?dGaussian for the definition of Gaussian distribution.
The sufficient statistics of a set of samples x (each row of x is a sample) are:

Usage

## S3 method for class 'GaussianGaussian'
sufficientStatistics(obj, x, foreach = FALSE, ...)

Arguments

obj

A "GaussianGaussian" object.

x

matrix, Gaussian samples, when x is a matrix, each row is a sample of dimension ncol(x). when x is a vector, x is length(x) samples of dimension 1.

foreach

logical, specifying whether to return the sufficient statistics for each observation. Default FALSE.

...

Additional arguments to be passed to other inherited types.

Value

If foreach=TRUE, will return a list of sufficient statistics for each row of x, otherwise will return the sufficient statistics of x as a whole.

References

Gelman, Andrew, et al. Bayesian data analysis. CRC press, 2013.

See Also

GaussianGaussian, sufficientStatistics_Weighted.GaussianGaussian

Examples

obj <- GaussianGaussian(gamma=list(Sigma=matrix(c(2,1,1,2),2,2),m=c(0.2,0.5),S=diag(2)))
x <- rGaussian(100,c(0,0),Sigma = matrix(c(2,1,1,2),2,2))
sufficientStatistics(obj = obj,x=x)
sufficientStatistics(obj = obj,x=x,foreach=TRUE)

[Package bbricks version 0.1.4 Index]