marginalNIW {mombf} | R Documentation |
Marginal likelihood under a multivariate Normal likelihood and a conjugate Normal-inverse Wishart prior.
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
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 |
Either a vector with column means of |
samplecov |
Either the sample covariance matrix |
n |
Either an integer indicating the sample size |
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
#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)