Learn R Programming

bbricks (version 0.1.4)

rPosteriorPredictive.GaussianInvWishart: Generate random samples from the posterior predictive distribution of a "GaussianInvWishart" object

Description

Generate random samples from the posterior predictive distribution of the following structure: $$x \sim Gaussian(mu,Sigma)$$ $$Sigma \sim InvWishart(v,S)$$ mu is known. Gaussian() is the Gaussian distribution. See ?dGaussian and ?dInvWishart for the definition of the distributions. The model structure and prior parameters are stored in a "GaussianInvWishart" object. Posterior predictive is a distribution of x|v,S,mu.

Usage

# S3 method for GaussianInvWishart
rPosteriorPredictive(obj, n, ...)

Arguments

obj

A "GaussianInvWishart" object.

n

integer, number of samples.

...

Additional arguments to be passed to other inherited types.

Value

A matrix of n rows, each row is a sample.

References

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

MARolA, K. V., JT KBNT, and J. M. Bibly. Multivariate analysis. AcadeInic Press, Londres, 1979.

See Also

GaussianInvWishart, dPosteriorPredictive.GaussianInvWishart

Examples

Run this code
# NOT RUN {
obj <- GaussianInvWishart(gamma=list(mu=c(-1.5,1.5),v=3,S=diag(2)))
x <- rGaussian(100,mu = c(-1.5,1.5),Sigma = matrix(c(0.1,0.03,0.03,0.1),2,2))
ss <- sufficientStatistics(obj=obj,x=x,foreach = FALSE)
## use x to update the prior informatoin
posterior(obj=obj,ss = ss)
## use the posterior to generate new samples
rPosteriorPredictive(obj = obj,n=20)
# }

Run the code above in your browser using DataLab