marginalNIW: Marginal likelihood under a multivariate Normal likelihood...

Description Usage Arguments Details Value Author(s) See Also Examples

Description

The argument z can be used to specify cluster allocations. If left missing then the usual marginal likelihood is computed, else it is computed conditional on the clusters (this is equivalent to the product of marginal likelihoods across clusters)

Usage

1
2
marginalNIW(x, xbar, samplecov, n, z, g,  mu0=rep(0,ncol(x)),
nu0=ncol(x)+4, S0, logscale=TRUE)

Arguments

x

Data matrix (individuals in rows, variables in columns). Alternatively you can leave missing and specify xbar, samplecov and n instead

xbar

Either a vector with column means of x or a list where each element corresponds to the column means for each cluster

samplecov

Either the sample covariance matrix cov(x) or a list where each element contains the covariance for each clsuter

n

Either an integer indicating the sample size nrow(x) or a vector indicating the cluster counts table(z)

z

Optional argument specifying cluster allocations

g

Prior dispersion parameter for mu

mu0

Prior mean for mu

nu0

Prior degrees of freedom for Sigma

S0

Prior scale matrix for Sigma, by default set to I/nu0

logscale

set to TRUE to get the log-posterior density

Details

The function computes

p(x)= int p(x | mu,Sigma) p(mu,Sigma) dmu dSigma

where p(x[i])= N(x[i]; mu,Sigma) iid i=1,...,n

p(mu | Sigma)= N(mu; mu0, g Sigma) p(Sigma)= IW(Sigma; nu0, S0)

Value

If z is missing the integrated likelihood under a Normal-IW prior. If z was specified then the product of integrated likelihoods across clusters

Author(s)

David Rossell

See Also

dpostNIW for the posterior Normal-IW density.

Examples

1
2
3
4
5
6
7
8
9
#Simulate data
x= matrix(rnorm(100),ncol=2)

#Integrated likelihood under correct model
marginalNIW(x,g=1,nu0=4,log=FALSE)

#Integrated likelihood under random cluster allocations
z= rep(1:2,each=25)
marginalNIW(x,z=z,g=1,nu0=4,log=FALSE)

mombf documentation built on Dec. 6, 2019, 3:01 a.m.