Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


bbricks (version 0.1.4)

sufficientStatistics: Get sample sufficient statistics

Description

This is a generic function that will generate the sufficient statistics of a given Bayesian bricks object. i.e. for the model structure: theta|gammaH(gamma) x|thetaF(theta) get the sufficient statistics T(x). For a given sample set x, each row of x is an observation, and a Bayesian bricks object obj. sufficientStatistics() return the sufficient statistics for different model structures:

class(obj)="LinearGaussianGaussian"

xGaussian(Az+b,Sigma) zGaussian(m,S) The sufficient statistics are:

  • SA = sumi=1:NAiTSigma1Ai

  • SAx = sumi=1:NAiTSigma1(xibi)

See ?sufficientStatistics.LinearGaussianGaussian for details.

class(obj)="GaussianGaussian"

Where xGaussian(mu,Sigma) muGaussian(m,S) Sigma is known. The sufficient statistics are:

  • N: the effective number of samples.

  • xsum: the row sums of the samples.

See ?sufficientStatistics.GaussianGaussian for details.

class(obj)="GaussianInvWishart"

Where xGaussian(mu,Sigma) SigmaInvWishart(v,S) mu is known. The sufficient statistics are:

  • N: the effective number of samples.

  • xsum: the sample scatter matrix centered on the mean vector.

See ?sufficientStatistics.GaussianInvWishart for details.

class(obj)="GaussianNIW"

Where xGaussian(mu,Sigma) SigmaInvWishart(v,S) muGaussian(m,Sigma/k) The sufficient statistics are:

  • N: the effective number of samples.

  • xsum: the row sums of the samples.

  • S: the uncentered sample scatter matrix.

See ?sufficientStatistics.GaussianNIW for details.

class(obj)="GaussianNIG"

Where xGaussian(Xbeta,sigma2) sigma2InvGamma(a,b) betaGaussian(m,sigma2V) X is a row vector, or a design matrix where each row is an obervation. The sufficient statistics are:

  • N: the effective number of samples.

  • SXx: covariance of X and x

  • SX: the uncentered sample scatter matrix.

  • Sx: the variance of x

See ?sufficientStatistics.GaussianNIG for details.

class(obj)="CatDirichlet"

Where xCategorical(pi) piDirichlet(alpha) The sufficient statistics of CatDirichlet object can either be x itself, or the counts of the unique labels in x. See ?sufficientStatistics.CatDirichlet for details.

class(obj)="CatDP"

Where xCategorical(pi) piDirichletProcess(alpha) The sufficient statistics of CatDP object can either be x itself, or the counts of the unique labels in x. See ?sufficientStatistics.CatDP for details.

class(obj)="DP"

Where pi|alphaDP(alpha,U) z|piCategorical(pi) thetaz|psiH0(psi) x|thetaz,zF(thetaz) The sufficient statistics of "DP" object is the same sufficient statistics of the "BasicBayesian" inside the "DP". See ?sufficientStatistics.DP for details.

class(obj)="HDP"

Where G|gammaDP(gamma,U) pij|G,alphaDP(alpha,G),j=1:J z|pijCategorical(pij) k|z,GCategorical(G), if z is a sample from the base measure G thetak|psiH0(psi) The sufficient statistics of "HDP" object is the same sufficient statistics of the "BasicBayesian" inside the "HDP". See ?sufficientStatistics.HDP for details.

class(obj)="HDP2"

Where G|etaDP(eta,U) Gm|gamma,GDP(gamma,G),m=1:M pimj|Gm,alphaDP(alpha,Gm),j=1:Jm z|pimjCategorical(pimj) k|z,GmCategorical(Gm), if z is a sample from the base measureGm u|k,GCategorical(G), if k is a sample from the base measureG thetau|psiH0(psi) x|thetau,uF(thetau) The sufficient statistics of "HDP2" object is the same sufficient statistics of the "BasicBayesian" inside the "HDP2". See ?sufficientStatistics.HDP2 for details.

Usage

sufficientStatistics(obj, x, ...)

Arguments

obj

a "BayesianBrick" object used to select a method.

x

a set of samples.

...

further arguments passed to or from other methods.

Value

An object of corresponding sufficient statistics class, such as "ssGaussian"

See Also

sufficientStatistics.LinearGaussianGaussian for Linear Gaussian and Gaussian conjugate structure, sufficientStatistics.GaussianGaussian for Gaussian-Gaussian conjugate structure, sufficientStatistics.GaussianInvWishart for Gaussian-Inverse-Wishart conjugate structure, sufficientStatistics.GaussianNIW for Gaussian-NIW conjugate structure, sufficientStatistics.GaussianNIG for Gaussian-NIG conjugate structure, sufficientStatistics.CatDirichlet for Categorical-Dirichlet conjugate structure, sufficientStatistics.CatDP for Categorical-DP conjugate structure ...

Examples

Run this code
# NOT RUN {
x <- rGaussian(10,mu = 1,Sigma = 1)
obj <- GaussianNIW()                    #an GaussianNIW object
sufficientStatistics(obj=obj,x=x)
# }

Run the code above in your browser using DataLab