# MAP: Get the Maximum A Posteriori(MAP) estimate of a... In bbricks: Bayesian Methods and Graphical Model Structures for Statistical Modeling

## Description

This is a generic function that will generate the MAP estimate of a given "BayesianBrick" object. For the model structure:

theta|gamma \sim H(gamma)

x|theta \sim F(theta)

MAP estimate of theta is theta_MAP = argmax_theta p(theta|gamma,x). For a given Bayesian bricks object obj, the MAP estimate will be:

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

Where

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

z \sim Gaussian(m,S)

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

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

Where

x \sim Gaussian(mu,Sigma)

mu \sim Gaussian(m,S)

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

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

Where

x \sim Gaussian(mu,Sigma)

Sigma \sim InvWishart(v,S)

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

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

Where

x \sim Gaussian(mu,Sigma)

Sigma \sim InvWishart(v,S)

mu \sim Gaussian(m,Sigma/k)

`MAP()` will return the MAP estimate of mu and Sigma. See `?MAP.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. `MAP()` will return the MAP estimate of beta and sigma^2. See `?MAP.GaussianNIG` for details.

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

Where

x \sim Categorical(pi)

pi \sim Dirichlet(alpha)

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

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

Where

x \sim Categorical(pi)

pi \sim DirichletProcess(alpha)

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

## Usage

 `1` ```MAP(obj, ...) ```

## Arguments

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

## Value

A list of the MAP estimates

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