Learn R Programming

rwc (version 1.12)

rGenWish: Simulate realizations from the Generalized Wishart distribution

Description

Simulates Wishart random variables, then computes the induced distance of the simulated Wishart random variables. The result is a random matrix distributed as a Generalized Wishart random variable.

Usage

rGenWish(Sigma, df)

Value

A matrix of dimension equal to the dimension of Sigma.

Arguments

Sigma

The covariance parameter of the Generalized Wishart.

df

An integer specifying the degrees of freedom.

Author

Ephraim M. Hanks

References

McCullagh 2009. Marginal likelihood for distance matrices. Statistica Sinica 19: 631-649.

Examples

Run this code
ras=raster(nrow=30,ncol=30)
extent(ras) <- c(0,30,0,30)
values(ras) <- 1
int=ras
cov.ras=ras

## get precision matrix of entire graph
B.int=get.TL(int)
Q.int=get.Q(B.int,1)

## get precision at a few nodes
Phi=get.Phi(Q.int,obs.idx=1:20)
S=ginv(as.matrix(Phi))

## simulate distance matrix
Dsim=rGenWish(df=20,Sigma=S)
image(Dsim)

## calculate log-likelihood
ll=dGenWish(Dsim,S,df=20,log=TRUE)
ll

Run the code above in your browser using DataLab