Want to share your content on R-bloggers? click here if you have a blog, or here if you don't. Paulo (from the Instituto de Matemática e Estatística, Universidade de São Paulo, Brazil) has posted an answer to my earlier question both as a comment on the ‘Og and as a solution on StackOverflow (with a much more readable LaTeX output). His solution is based on the observation that the multidimensional log-normal distribution still allows for closed form expressions of both the mean and the variance and that those expressions can further be inverted to impose the pair (μ,Σ)  on the log-normal vector. In addition, he shows that the only constraint on the covariance matrix is that the covariance σij is larger than iμj.. Very neat!

In the meanwhile, I corrected my earlier R code on the gamma model, thanks to David Epstein pointing a mistake in the resolution of the moment equation and I added the constraint on the covariance, already noticed by David in his question. Here is the full code:

sol=function(mu,sigma){
solub=TRUE
alpha=rep(0,3)
beta=rep(0,2)
beta=mu/sigma
alpha=mu*beta
coef=mu*sigma-mu*sigma
if (coef<0){
solub=FALSE}else{
beta=coef/(sigma*sigma-sigma^2)
alpha=sigma*beta/sigma^2
alpha=mu*beta-mu*alpha
if (alpha    }
list(solub=solub,alpha=alpha,beta=beta)
}

mu=runif(2,0,10);sig=c(mu^2/runif(1),mu^2/runif(1));sol(mu,c(sig,runif(1,max(-sqrt(prod(sig)),
-mu*mu),sqrt(prod(sig)))))


and did not get any FALSE outcome when running this code several times.

Filed under: R, Statistics, University life Tagged: covariance matrix, log-normal distribution, multivariate analysis, Stieltjes conditions, trains        