sufficientStatistics_Weighted {bbricks} R Documentation

## Get weighted sample sufficient statistics

### Description

This is a generic function that will generate the weighted sufficient statistics of a given "BayesianBrick" object. That is, for the model structure:

theta|gamma \sim H(gamma)

x|theta \sim F(theta)

get the weighted sufficient statistics T(x). For a given sample set x, each row of x is an observation, the sample weights w, and a Bayesian bricks object obj. `sufficientStatistics_Weighted()` return the weighted sufficient statistics for different model structures:

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

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

z \sim Gaussian(m,S)

The sufficient statistics are:

• SA = sum_{i=1:N} w_i A_i^T Sigma^{-1} A_i

• SAx = sum_{i=1:N} w_i A_i^T Sigma^{-1} (x_i-b_i)

See `?sufficientStatistics.LinearGaussianGaussian` for details.

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

Where

x \sim Gaussian(mu,Sigma)

mu \sim Gaussian(m,S)

Sigma is known. The sufficient statistics are:

• N: the effective number of samples.

• xsum: the row sums of the samples.

See `?sufficientStatistics_Weighted.GaussianGaussian` for details.

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

Where

x \sim Gaussian(mu,Sigma)

Sigma \sim InvWishart(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_Weighted.GaussianInvWishart` for details.

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

Where

x \sim Gaussian(mu,Sigma)

Sigma \sim InvWishart(v,S)

mu \sim Gaussian(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_Weighted.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. 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_Weighted.GaussianNIG` for details.

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

Where

x \sim Categorical(pi)

pi \sim Dirichlet(alpha)

The sufficient statistics of CatDirichlet object can either be x itself, or the counts of the unique labels in x.
See `?sufficientStatistics_Weighted.CatDirichlet` for details.

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

Where

x \sim Categorical(pi)

pi \sim DirichletProcess(alpha)

The sufficient statistics of CatDP object can either be x itself, or the counts of the unique labels in x.
See `?sufficientStatistics_Weighted.CatDP` for details.

#### class(obj)="DP"

Where

pi|alpha \sim DP(alpha,U)

z|pi \sim Categorical(pi)

theta_z|psi \sim H0(psi)

x|theta_z,z \sim F(theta_z)

The sufficient statistics of "DP" object is the same sufficient statistics of the "BasicBayesian" inside the "DP". See `?sufficientStatistics_Weighted.DP` for details.

#### class(obj)="HDP"

Where

G|gamma \sim DP(gamma,U)

pi_j|G,alpha \sim DP(alpha,G), j = 1:J

z|pi_j \sim Categorical(pi_j)

k|z,G \sim Categorical(G),\textrm{ if z is a sample from the base measure G}

theta_k|psi \sim H0(psi)

The sufficient statistics of "HDP" object is the same sufficient statistics of the "BasicBayesian" inside the "HDP". See `?sufficientStatistics_Weighted.HDP` for details.

#### class(obj)="HDP2"

Where

G |eta \sim DP(eta,U)

G_m|gamma,G \sim DP(gamma,G), m = 1:M

pi_{mj}|G_m,alpha \sim DP(alpha,G_m), j = 1:J_m

z|pi_{mj} \sim Categorical(pi_{mj})

k|z,G_m \sim Categorical(G_m),\textrm{ if z is a sample from the base measure } G_m

u|k,G \sim Categorical(G),\textrm{ if k is a sample from the base measure } G_m

theta_u|psi \sim H0(psi)

x|theta_u,u \sim F(theta_u)

The sufficient statistics of "HDP2" object is the same sufficient statistics of the "BasicBayesian" inside the "HDP2". See `?sufficientStatistics_Weighted.HDP2` for details.

### Usage

```sufficientStatistics_Weighted(obj, x, w, ...)
```

### Arguments

 `obj` a "BayesianBrick" object used to select a method. `x` a set of samples. `w` numeric, sample weights. `...` further arguments passed to or from other methods.

### Value

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

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

### Examples

```
x <- rGaussian(10,mu = 1,Sigma = 1)
w <- runif(10)
obj <- GaussianNIW()                    #an GaussianNIW object
sufficientStatistics_Weighted(obj=obj,x=x,w=w)

```

[Package bbricks version 0.1.4 Index]