# MPE: Get the Mean Posterior Estimate(MPE) of a "BayesianBrick"... In bbricks: Bayesian Methods and Graphical Model Structures for Statistical Modeling

## Description

This is a generic function that will generate the MPE estimate of a given "BayesianBrick" object. i.e. for the model structure:

theta|gamma \sim H(gamma)

x|theta \sim F(theta)

MPE estimate of theta is theta_MPE = E(theta|gamma,x), E() is the expectation function. For a given Bayesian bricks object obj, the MPE estimate will be:

#### class(obj)="LinearGaussianGaussian"

Where

x \sim Gaussian(A z + b, Sigma)

z \sim Gaussian(m,S)

`MPE()` will return the MPE estimate of z. See `?MPE.LinearGaussianGaussian` for details.

#### class(obj)="GaussianGaussian"

Where

x \sim Gaussian(mu,Sigma)

mu \sim Gaussian(m,S)

Sigma is known. `MPE()` will return the MPE estimate of mu. See `?MPE.GaussianGaussian` for details.

#### class(obj)="GaussianInvWishart"

Where

x \sim Gaussian(mu,Sigma)

Sigma \sim InvWishart(v,S)

mu is known. `MPE()` will return the MPE estimate of Sigma. See `?MPE.GaussianInvWishart` for details.

#### class(obj)="GaussianNIW"

Where

x \sim Gaussian(mu,Sigma)

Sigma \sim InvWishart(v,S)

mu \sim Gaussian(m,Sigma/k)

`MPE()` will return the MPE estimate of mu and Sigma. See `?MPE.GaussianNIW` for details.

#### class(obj)="GaussianNIG"

Where

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

sigma^2 \sim InvGamma(a,b)

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

X is a row vector, or a design matrix where each row is an obervation. `MPE()` will return the MPE estimate of beta and sigma^2. See `?MPE.GaussianNIG` for details.

#### class(obj)="CatDirichlet"

Where

x \sim Categorical(pi)

pi \sim Dirichlet(alpha)

`MPE()` will return the MPE estimate of pi. See `?MPE.CatDirichlet` for details.

#### class(obj)="CatDP"

Where

x \sim Categorical(pi)

pi \sim DirichletProcess(alpha)

`MPE()` will return the MPE estimate of pi. See `?MPE.CatDP` for details.

## Usage

 `1` ```MPE(obj, ...) ```

## Arguments

 `obj` A "BayesianBrick" object used to select a method. `...` further arguments passed to or from other methods.

## Value

A list of MPE estimates

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