sufficientStatistics_Weighted.GaussianGaussian {bbricks}R Documentation

Weighted 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) and weights w are:

Usage

## S3 method for class 'GaussianGaussian'
sufficientStatistics_Weighted(obj, x, w, 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.

w

numeric, sample weights.

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.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))
w <- runif(100)
sufficientStatistics_Weighted(obj=obj,x=x,w=w,foreach = FALSE)
sufficientStatistics_Weighted(obj=obj,x=x,w=w,foreach = TRUE)

[Package bbricks version 0.1.4 Index]