GaussianNIG {bbricks}R Documentation

Create objects of type "GaussianNIG".

Description

Create an object of type "GaussianNIG", which represents the Gaussian and Normal-Inverse-Gamma (Gaussian-NIG) conjugate structure:

x \sim Gaussian(X beta,sigma^2)

sigma^2 \sim InvGamma(a,b)

beta \sim Gaussian(m,sigma^2 V)

Where X is a row vector, or a design matrix where each row is an obervation. InvGamma() is the Inverse-Gamma distribution, Gaussian() is the Gaussian distribution. See ?dInvGamma and dGaussian for the definitions of these distribution.
This object will be used as a place for recording and accumulating information in the related inference/sampling functions such as posterior(), posteriorDiscard(), MAP(), marginalLikelihood(), dPosteriorPredictive(), rPosteriorPredictive() and so on.

Usage

GaussianNIG(
  objCopy = NULL,
  ENV = parent.frame(),
  gamma = list(m = 0, V = 1, a = 1, b = 1)
)

Arguments

objCopy

An object of type "GaussianNIG". If "objCopy" is not NULL, the function create a new "GaussianNIG" object by copying the content from objCopy, otherwise this new object will be created by using "ENV" and "gamma". Default NULL.

ENV

environment, specify in which environment the object will be created

gamma

list, a named list of NIG parameters, gamma=list(m,V,a,b). Where gamma$m is a numeric "location" parameter; gamma$V is a symmetric positive definite matrix representing the "scale" parameters; gamma$a and gamma$b are the "shape" and "scale" parameter of the Inverse Gamma distribution.

Value

An object of class "GaussianNIG".

References

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

See Also

posterior.GaussianNIG,posteriorDiscard.GaussianNIG,MAP.GaussianNIG,MPE.GaussianNIG,marginalLikelihood.GaussianNIG,dPosteriorPredictive.GaussianNIG, rPosteriorPredictive.GaussianNIG ...

Examples


X <- 1:20                               #generate some linear data
x <- rnorm(20)+ X*0.3                   #generate some linear data
obj <- GaussianNIG(gamma=list(m=0,V=1,a=1,b=0)) #create a GaussianNIG object
ss <- sufficientStatistics(obj = obj,X=X,x=x)   #the sufficient statistics of X and x
posterior(obj = obj,ss = ss)                    #add the infomation to the posterior
MAP(obj)                                        #get the MAP estimate of beta and sigma^2
## print the whole content, "invV" and "mVm" in the output are temporary variables.
obj


[Package bbricks version 0.1.4 Index]