posteriorDiscard.GaussianGaussian: Update a "GaussianGaussian" object with sample sufficient...

Description Usage Arguments Value References See Also Examples

View source: R/Gaussian_Inference.r

Description

For the 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.
Contrary to posterior(), this function will update (m,S) by removing the information of observed samples x. The model structure and prior parameters are stored in a "GaussianGaussian" object, the prior parameters in this object will be updated after running this function.

Usage

1
2
## S3 method for class 'GaussianGaussian'
posteriorDiscard(obj, ss, w = NULL, ...)

Arguments

obj

A "GaussianGaussian" object.

ss

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

w

Sample weights, default NULL.

...

Additional arguments to be passed to other inherited types.

Value

None. the gamma stored in "obj" will be updated based on "ss".

References

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

See Also

GaussianGaussian,posterior.GaussianGaussian,sufficientStatistics.GaussianGaussian

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
obj <- GaussianGaussian(gamma=list(Sigma=matrix(c(2,1,1,2),2,2),m=c(0.2,0.5),S=diag(2)))
obj
x <- rGaussian(100,c(0,0),Sigma = matrix(c(2,1,1,2),2,2))
ss <- sufficientStatistics(obj=obj,x=x,foreach = FALSE)
## update prior into posterior
posterior(obj = obj,ss = ss)
obj
## remove the information, back to prior
posteriorDiscard(obj = obj,ss = ss)
obj

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