Learn R Programming

bbricks (version 0.1.1)

sufficientStatistics_Weighted.GaussianNIG: Weighted sufficient statistics of a "GaussianNIG" object

Description

For following Gaussian-NIG model structure: beta,sigma^2|gamma ~ NIG(gamma) x|beta,sigma^2,X ~ Gaussian(X where gamma = (m,V,a,b) is the Normal-Inverse-Gamma(NIG) parameter, "m" is a numeric "location" parameter; "V" is a symmetric positive definite matrix representing the "scale" parameters; "a" and "b" are the "shape" and "rate" parameter of the Inverse Gamma distribution. The model structure and prior parameters are stored in a "GaussianNIG" object. This object will be used as a place for recording and accumulating information in the related inference/sampling functions such as posterior(), posteriorDiscard(), MAP() and so on. The sufficient statistics of a set of samples (x,X) and weights ware: the effective number of samples N=sum(w); the covariance of X and x SXx=t(w*X) the covariance of X SX=t(w*X) the covariance of x Sx=t(w*x)

Usage

# S3 method for GaussianNIG
sufficientStatistics_Weighted(obj, x, w, X, foreach = FALSE, ...)

Arguments

obj

A "GaussianNIG" object.

x

numeric, must satisfy length(x) = nrow(X).

w

numeric, sample weights.

X

matrix, must satisfy length(x) = nrow(X).

foreach

logical, if foreach=TRUE, will return a list of sufficient statistics for each (x,X), otherwise will return the sufficient statistics as a whole.

...

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,X), otherwise will return the sufficient statistics of (x,X) as a whole.

References

Banerjee, Sudipto. "Bayesian Linear Model: Gory Details." Dowloaded from http://www. biostat. umn. edu/~ ph7440 (2008).

See Also

GaussianNIG, sufficientStatistics.GaussianNIG

Examples

Run this code
# NOT RUN {
obj <- GaussianNIG(gamma=list(m=0,V=1,a=1,b=0))
X <- 1:20
x <- rnorm(20)+ X*0.3
w <- runif(20)
sufficientStatistics_Weighted(obj = obj,X=X,x=x,w=w)
sufficientStatistics_Weighted(obj = obj,X=X,x=x,w=w,foreach = TRUE)
# }

Run the code above in your browser using DataLab