powered by
nmat converts a covariance matrix (stored as a vector, col by col) to a correlation matrix (also stored as a vector).
nmat
nmat(vec)
k x k Cov matrix stored as a k*k x 1 vector (col by col)
k*k x 1 vector with correlation matrix
This routine is a utility routine that does not check the input arguments for proper dimensions and type.
This routine is often used with apply to convert an R x (k*k) array of covariance MCMC draws to correlations. As in corrdraws=apply(vardraws,1,nmat)
corrdraws=apply(vardraws,1,nmat)
## set.seed(66) X=matrix(rnorm(200,4),ncol=2) Varmat=var(X) nmat(as.vector(Varmat))
Run the code above in your browser using DataLab